【问题标题】:Why doesn't Win32::ODBC find the ODBC.dll under Perl 5.10 and Cygwin?为什么 Win32::ODBC 在 Perl 5.10 和 Cygwin 下找不到 ODBC.dll?
【发布时间】:2010-10-23 23:08:55
【问题描述】:

我正在尝试使用 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)

【问题讨论】:

    标签: windows database perl odbc cygwin


    【解决方案1】:

    我已验证该 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
    

    【讨论】:

      【解决方案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
      

      【讨论】:

      • 感谢您的信息。事实证明,我最终删除了我的 Cygwin Perl 安装,而只使用了 ActivePerl。然后我更新了我的 Cygwin 路径以适应。
      猜你喜欢
      • 2010-10-15
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 1970-01-01
      • 1970-01-01
      • 2015-10-25
      • 1970-01-01
      • 2010-11-02
      相关资源
      最近更新 更多