我正在尝试使用Perl ODBC连接到Microsoft SQL服务器.我的问题是Perl 5.10.0使用Win32 ODBC驱动程序时遇到问题.
如果我运行Perl shell并执行这一行,我会收到错误.
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.
我已经验证了dll文件确实存在.
我已经安装了Cygwin包:
> perl(5.10.0-5)
> perl-libwin32(0.28-2)
最佳答案 这似乎是
known issue.抓住
libiodbc source,应用以下补丁,构建和安装:
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;
更新:Cygwin人员have a TODO for this issue,但现在已经有几个月了.如果等待的时间太长,你可以在此期间伪造它:
#! /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