I struggled whole day with this issue and failed to compile this on my Windows 7 box.
My setup is Ruby 1.9.3p0 (from Ruby Installer) or Ruby 1.9.3p194 (Bitnami Rubystack)
on Windows 7 Enterprise SP1, Ruby DevKit 4.5.2 (2011-12-29) and MS Visual Studio 9.0
(the only one with lib.exe working for me from different MS SKD Devel sets).
I followed https://github.com/alexey-chebotar/ruby-ldap/wiki/How-to-compile-ruby-ldap-on-Windows for compile instruction and modified the header files and replaced few remaining STR2CSTR with StringValueCStr. With other issues (MS Libs, searching for lib.exe and other) I spent all day on this and ended with:
conn.c: In function 'rb_ldap_conn_free':
conn.c:32:7: warning: implicit declaration of function 'ldap_unbind'
conn.c: In function 'rb_ldap_conn_get_option':
conn.c:559:2: warning: passing argument 1 of 'ldap_init' discards qualifiers from pointer target type
./win/winldap.h:264:7: note: expected 'PCHAR' but argument is of type 'const char *'
conn.c: In function 'rb_ldap_conn_result2error':
conn.c:712:3: error: lvalue required as unary '&' operand
conn.c:714:3: warning: implicit declaration of function 'ldap_result2error'
conn.c: In function 'rb_ldap_conn_invalidate_entry':
conn.c:763:3: error: lvalue required as unary '&' operand
conn.c: In function 'rb_ldap_parse_result':
conn.c:965:3: warning: implicit declaration of function 'ldap_parse_result'
make: *** [conn.o] Error 1
I gave up here (I am allergic to C), desperate and exhausted, searching for other options and found the pre-compiled version from Nazy (https://github.com/downloads/nazy/ruby-ldap/ruby-ldap-0.9.11-x86-mingw32.gem) - many thanks for that.
I thank you guys for the effort you made the and I hope I will still be able to use this lib in the future. I was using pre-compiled 0.9.8 with my Rails2 project, I hope this one will work well with Rails3.
Let me know if I can help with any testing etc.
This problem is caused by 2 matters.
First, gcc could not find wldap32.lib when linking time.
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\wldap32.lib
Second, ruby-ldap using function which not implemented in wldap32.
Any idea what to do to fix this?
gem install ruby-ldap
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing ruby-ldap:
ERROR: Failed to build gem native extension.
checking for winldap.h... yes
checking for winlber.h... yes
checking for sys/time.h... yes
checking for main() in -lwldap32... yes
checking for ldap_init() in ldap.h... no
checking for ldap_set_option()... yes
checking for ldap_get_option()... yes
checking for ldap_memfree()... yes
checking for ldap_perror()... yes
checking for ldap_sort_entries()... no
checking for ldapssl_init()... no
checking for ldap_sslinit()... yes
checking for ldap_sasl_bind_s()... no
checking for ldap_rename_s()... no
checking for ldap_compare_s()... yes
checking for ldap_add_ext_s()... yes
checking for ldap_compare_ext_s()... yes
checking for ldap_delete_ext_s()... yes
checking for ldap_modify_ext_s()... yes
checking for ldap_search_ext_s()... yes
checking for ldap_unbind_ext_s()... no
checking for ldap_sasl_interactive_bind_s()... no
In file included from c:/Tools/ruby193/include/ruby-1.9.1/ruby/missing.h:32:0,
c:\ruby-193-devkit\mingw\bin../lib/gcc/mingw32/4.5.2/../../../../include/sys/time.h:39:29: error: conflicting types for 'gettimeofday'
c:/Tools/ruby193/include/ruby-1.9.1/ruby/win32.h:283:12: note: previous declaration of 'gettimeofday' was here
In file included from c:/Tools/ruby193/include/ruby-1.9.1/ruby/ruby.h:1382:0,
c:/Tools/ruby193/include/ruby-1.9.1/ruby/missing.h:51:8: error: redefinition of 'struct timezone'
c:/Tools/ruby193/include/ruby-1.9.1/ruby/win32.h:212:8: note: originally defined here
make: *** [clientauth.o] Error 1
make failed, exit code 2
Gem files will remain installed in C:/Tools/ruby193/lib/ruby/gems/1.9.1/gems/ruby-ldap-0.9.16 for inspection.
Results logged to C:/Tools/ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/ruby-ldap-0.9.16/gem_make.out