Bug #15097
openGem install fails on Ruby 2.5.1 with Cygwin (get_dns_server_list undefined)
Description
Compiled and installed Ruby 2.5.1 on Cygwin, and now gem install fails with:
ERROR: While executing gem ... (NameError)
undefined local variable or method `get_dns_server_list' for Win32::Resolv:Module
While building Ruby I got the following warning:
win32/resolv:
Could not be configured. It will not be installed.
Check ext/win32/resolv/mkmf.log for more details.
The error in mkmf.log is:
/ruby-2.5.1/ext/win32/resolv/conftest.c:14: undefined reference to `GetNetworkParams'
collect2: error: ld returned 1 exit status
The mkmf.log is also attached.
Could not figure out how to fix this problem.
Is 2.5.1 not compatible with Cygwin?
Files
Updated by caspercg (Casper G) about 6 years ago
- Subject changed from Gem install fails on Ruby 2.5.1 (get_dns_server_list undefined) to Gem install fails on Ruby 2.5.1 with Cygwin (get_dns_server_list undefined)
Updated by nobu (Nobuyoshi Nakada) about 6 years ago
I can't reproduce it, with the trunk and 2.5.2 in the repository, using
$ LANG=C i686-pc-cygwin-gcc -v
Using built-in specs.
COLLECT_GCC=i686-pc-cygwin-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/6.4.0/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with: /usr/src/ports/cygwin32-gcc/cygwin32-gcc-6.4.0-1.x86_64/src/gcc-6.4.0/configure --srcdir=/usr/src/ports/cygwin32-gcc/cygwin32-gcc-6.4.0-1.x86_64/src/gcc-6.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/cygwin32-gcc --htmldir=/usr/share/doc/cygwin32-gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --with-sysroot=/usr/i686-pc-cygwin/sys-root --with-build-sysroot=/usr/i686-pc-cygwin/sys-root --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-__cxa_atexit --with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-languages=c,c++,fortran,lto --enable-graphite --enable-linker-build-id --enable-clocale=gnu --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --disable-symvers --with-default-libstdcxx-abi=gcc4-compatible --with-gnu-ld --with-gnu-as --with-system-zlib
Thread model: posix
gcc version 6.4.0 (GCC)
The last try for GetNetworkParams
is:
"gcc -o conftest.exe -I../../../.ext/include/i386-cygwin -I../../../../src/include -I../../../../src/ext/win32/resolv -D_XOPEN_SOURCE -D_GNU_SOURCE -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict conftest.c -L. -L../../.. -L. -fstack-protector -lruby250-static -liphlpapi -lpthread -lgmp -ldl "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void GetNetworkParams();
14: int t(void) { GetNetworkParams(); return 0; }
/* end */
and seems no significant differences than yours.
Updated by caspercg (Casper G) about 6 years ago
nobu (Nobuyoshi Nakada) wrote:
I can't reproduce it, with the trunk and 2.5.2 in the repository, using
Thanks for taking a look at it.
This is on a 32-bit Windows, if that has any significance?
However I now figured out a workaround and got it to work.
1: ext/win32/resolv/extconf.rb
has to be modified like so:
# if have_library('iphlpapi', 'GetNetworkParams')
create_makefile('win32/resolv')
# end
I.e. the test for GetNetworkParams has to be commented out, because this is the test that starts all the trouble.
2: Once ext/win32/resolv/Makefile
has been generated then -liphlpapi
has to be manually added to the LIBS
line in the Makefile.
Now everything compiles, and the resolver works as it should.
3: However there is one more thing which needs to be done, and that is a full Cygwin rebase of the Ruby dynamic link libraries, otherwise you will get a lot of errors like this:
9876 child_info_fork::abort: address space needed by 'utf_16be.so' (0x270000) is already occupied
For anyone else running into this issue follow the instructions for rebasing here:
https://github.com/rvm/rvm/issues/3309
And here:
http://cygwin.wikia.com/wiki/Rebaseall
After these 3 steps are done, I now have it fully working.
I think there is something wrong with the 32-bit detection of GetNetworkParams(?), also it seems there's a missing rebase at the end of the installation.
In any case, with the above tricks, it works fine now.
Updated by hsbt (Hiroshi SHIBATA) 8 months ago
- Status changed from Open to Assigned