2009-05-05 33 views
4

我正在嘗試使用Perl ODBC連接到Microsoft SQL服務器。我的問題是Perl 5.10.0使用Win32 ODBC驅動程序時遇到問題。爲什麼Win32 :: ODBC在Perl 5.10和Cygwin下找不到ODBC.dll?

如果我運行一個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)

回答

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; 

UPDATE: 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 
+0

感謝您的信息。事實證明,我最終刪除了我的Cygwin Perl安裝,而只是使用了ActivePerl。然後我更新了我的Cygwin路徑以適應。 – 2009-06-25 17:34:53

0

我驗證過該dll文件確實存在。

您的意思是說/usr/lib/perl5/vendor_perl/5.10/i686-cygwin/auto/Win32/ODBC/ODBC.dll是否存在?如果是這樣,你有讀取和執行權限?

有略高於/usr/lib/perl5/5.10/i686-cygwin/DynaLoader.pm線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. 

如此看來事情是不對您的安裝。你可以嘗試重新安裝的Win32 :: ODBC有:

$ cpan Win32::ODBC 
相關問題