I am attempting to use Perl ODBC for connecting to some Microsoft SQL server. My issue is that Perl 5.10. is getting an issue while using Win32 ODBC driver.

Basically operate a Perl spend and execute that one line, I recieve errors.

use Win32::ODBC;

Can't load '/usr/lib/perl5/vendor_perl/5.10/i686-cygwin/auto/Win32/ODBC/ODBC.dll'
for module Win32::ODBC: No such file or directory at
/usr/lib/perl5/5.10/i686-cygwin/DynaLoader.pm line 201.

I have verified the dll file does exist.

I have installed the Cygwin packages:

  • perl (5.10.-5)
  • perl-libwin32 (.28-2)

This seems to become a known issue. Grab the libiodbc source, apply the next patch, build, and install:

diff -ub  libiodbc-3.52.6/include/iodbcunix.h.orig
--- libiodbc-3.52.6/include/iodbcunix.h.orig        2006-01-26 09:50:59.000000000 +0000
+++ libiodbc-3.52.6/include/iodbcunix.h     2007-12-24 19:33:57.859375000 +0000
@@ -124,6 +124,7 @@
 #if defined (OBSOLETE_WINDOWS_TYPES)
 typedef unsigned char              BYTE;
 #endif
+#ifndef WIN32
 typedef unsigned short             WORD;
 typedef unsigned int               DWORD;
 typedef char *                     LPSTR;
@@ -131,6 +132,7 @@         
 typedef wchar_t *          LPWSTR; 
 typedef const wchar_t *            LPCWSTR;
 typedef DWORD *                    LPDWORD;
+#endif

 #if !defined(BOOL) && !defined(_OBJC_OBJC_H_)
 typedef int                        BOOL;


UPDATE: the Cygwin folks have a TODO for this issue, but it is several several weeks old now. Just in case that's too lengthy to hold back, you are able to fake it meanwhile:

#! /bin/bash

# run from the libiodbc build directory

gcc -shared -o cygiodbc-2.dll \
    -Wl,--out-implib=libcygiodbc-2.dll.a \
    -Wl,--export-all-symbols \
    -Wl,--enable-auto-import \
    -Wl,--whole-archive iodbc/.libs/libiodbc.a \
    -Wl,--no-whole-archive

gcc -shared -o cygiodbcinst-2.dll \
    -Wl,--out-implib=libcygiodbcinst-2.dll.a \
    -Wl,--export-all-symbols \
    -Wl,--enable-auto-import \
    -Wl,--whole-archive iodbcinst/.libs/libiodbcinst.a \
    -Wl,--no-whole-archive

cp cygiodbc{,inst}-2.dll /bin

I have verified the dll file does exist.

Would you imply that /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/auto/Win32/ODBC/ODBC.dll is available? If that's the case, have you got read and execute permission?

There is a comment just above /usr/lib/perl5/5.10/i686-cygwin/DynaLoader.pm line 201:

# Many dynamic extension loading problems will appear to come from
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
# Often these errors are actually occurring in the initialisation
# C code of the extension XS file. Perl reports the error as being
# in this perl code simply because this was the last perl code
# it executed.

Therefore it appears something is wrong together with your installation. You could attempt re-installing Win32::ODBC with:

$ cpan Win32::ODBC