在 windows 上安装 ruby-ldap gem(使用 ruby 2.1.6)

Installing ruby-ldap gem on windows (using ruby 2.1.6)

我在 windows 上安装 ruby-ldap gem 时遇到问题(我有 ruby 2.1.6 并且配置了 devkit 来编译扩展)。当我尝试 gem 安装时出现以下错误,它会抛出以下错误

extconf.rb:197:in ``': Permission denied - lib /def:./win/wldap32.def /out:./win/wldap32.lib (Errno:
:EACCES)

我尝试以管理员身份安装 我尝试在我的 win 文件夹

中添加 wldap32.lib 文件

这是此问题的完整日志 暂时增强 PATH 以包含 DevKit ... 构建本机扩展。这可能需要一段时间... 错误:安装 ruby-ldap 时出错: 错误:无法构建 gem 本机扩展。

C:/Ruby21/bin/ruby.exe extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of      necessary libraries and/or headers.  Check the mkmf.log file for more details.You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby21/bin/ruby
        --with-netscape
        --without-netscape
        --without-netscape
        --with-mozilla
        --without-mozilla
        --without-mozilla
        --with-openldap1
        --without-openldap1
        --without-openldap1
        --with-openldap2
        --without-openldap2
        --without-openldap2
        --with-wldap32
        --without-wldap32
        --without-wldap32
        --with-ldap-dir
        --without-ldap-dir
        --with-ldap-include
        --without-ldap-include=${ldap-dir}/include
        --with-ldap-lib
        --without-ldap-lib=${ldap-dir}/lib
        --with-ldap-dir
        --without-ldap-dir
        --without-ldap-dir
        --with-ldap
        --without-ldap
        --without-ldap
extconf.rb:197:in ``': Permission denied - lib /def:./win/wldap32.def /out:./win/wldap32.lib (Errno:
:EACCES)
        from extconf.rb:197:in `<main>'
--with-wldap32

extconf failed, exit code 1

Windows 不受 READMEgem 官方支持

PORTS

  * FreeBSD ("Akinori -Aki- MUSHA" <knu@idaemons.org>)
  * Debian (Akira Yamada <akira@ruby-lang.org>)
-------------------------------------------------------------------------------

此外,还有 https://github.com/bearded/ruby-ldap/wiki/How-to-compile-ruby-ldap-on-Windows,但我不认为它适用于最新版本,这里有一些需要更改以支持它的内容。

  1. 它使用 lib,devkit 使用 link,所以它必须在 extconf.rb 中更改为 link /lib,这就是给你权限被拒绝的原因错误。
  2. 存在加载 time.h 问题,因此 time.h 的每个包含都必须更改为类似
  3. 的内容
#if HAVE_SYS_TIME_H && !defined(_WIN32)
#include 
#endif
  1. 在 extconf.rb 中应该是 have_header("sys/time.h") unless win32
  2. 最后但同样重要的是 conn.c:183: undefined reference toldap_initialize'most likely because something isn't installed, I'm thinkingldap.h`(读取 ldap 二进制文件)

所以,抱歉,我认为这是不行的。