Forum: Ruby-core [Ruby-Bug#3802][Open] freeaddrinfo not found in WS2_32.dll

Posted by Thomas Volkmar Worm (Guest)
on 2010-09-08 15:25
(Received via mailing list)
Bug #3802: freeaddrinfo not found in WS2_32.dll
http://redmine.ruby-lang.org/issues/show/3802

Author: Thomas Volkmar Worm
Status: Open, Priority: Normal
ruby -v: 1.9.2p0 (2010-08-18) [i386-mingw32]

It is an issue, which occurs on Windows 2000. It seems, as if it would 
be easy to fix it:

http://mailman.pculture.org/pipermail/admin/2010-April/000285.html

So if it is easy to fix, please do, because otherwise rubygems does not 
work.

(I am using the Ruby Installer)
Posted by Usaku NAKAMURA (Guest)
on 2010-09-08 18:54
(Received via mailing list)
Issue #3802 has been updated by Usaku NAKAMURA.

Status changed from Open to Third Party's Issue

How did you get the binary?

If you build ruby on your environment, it will not occur.
If you get the binary from others, ask the provider to add 
--enable-wide-addrinfo option when running configure.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3802
Posted by Luis Lavena (Guest)
on 2010-09-08 19:11
(Received via mailing list)
Issue #3802 has been updated by Luis Lavena.


Hello Mr. Nakamura

Binaries were provided by RubyInstaller project.

We were not aware of special configure flags required to deal with this. 
To our bad, there is not much documentation about build process for 
Ruby, specially Windows.

Adding this as a ticket to RubyInstaller:

http://github.com/oneclick/rubyinstaller/issues#issue/31
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3802
Posted by Luis Lavena (Guest)
on 2010-10-11 16:43
(Received via mailing list)
Issue #3802 has been updated by Luis Lavena.


Hello Mr. Nakamura,

It seems the flag you're mentioning is --enable-wide-getaddrinfo, not 
--enable-wide-addrinfo.

Checking the source code, I can't find any ifdef that could affect this.

Since I don't have a Windows 2000 installation around, how can we verify 
this compiled successfully?

Thank you.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3802
Posted by U.Nakamura (Guest)
on 2010-10-12 03:20
(Received via mailing list)
Hello,

In message "[ruby-core:32738] [Ruby-Bug#3802] freeaddrinfo not found in 
WS2_32.dll"
    on Oct.11,2010 23:42:55, <redmine@ruby-lang.org> wrote:
> It seems the flag you're mentioning is --enable-wide-getaddrinfo, not 
--enable-wide-addrinfo.
>
> Checking the source code, I can't find any ifdef that could affect this.

See ext/socket/extconf.rb.
When --enable-wide-getaddrinfo is specified, socket.so uses
ext/socket/getaddrinfo.c and ext/socket/getnameinfo.c.


> Since I don't have a Windows 2000 installation around, how can we verify this 
compiled successfully?

Wait bug report from real user :)


Regards,
Posted by Luis Lavena (Guest)
on 2010-10-13 01:41
(Received via mailing list)
Issue #3802 has been updated by Luis Lavena.


Hello Mr. Nakamura,

I think we have a problem on this. Using Windows 7 which provides a 
working freeaddrinfo compilation fails since it is already defined by 
MinGW headers:

<pre><code>
generating constant definitions
gcc -I. -I../../.ext/include/i386-mingw32 
-I../../../../../../ruby/include -I../../../../../../ruby/ext/socket 
-DRUBY_EXTCONF_H=\"extconf.h\" -I.    -D_WIN32_WINNT=0x501 -O3 -g 
-Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith
-Wwrite-strings -Wno-missing-field-initializers -Wno-long-long  -o 
init.o -c ../../../../../../ruby/ext/socket/init.c
In file included from 
../../../../../../ruby/ext/socket/rubysocket.h:101:0,
                 from ../../../../../../ruby/ext/socket/init.c:11:
../../../../../../ruby/ext/socket/addrinfo.h:175:13: error: conflicting 
types for 'freeaddrinfo'
c:\users\luis\projects\oss\oci\rubyinstaller\sandbox\devkit\mingw\bin\../lib/gcc/mingw32/4.5.1/../../../../include/ws2tcpip.h:298:13: 
note: previous declaration of 'freeaddrinfo' was here
make[1]: *** [init.o] Error 1
make[1]: Leaving directory 
`/c/Users/Luis/Projects/oss/oci/rubyinstaller/sandbox/ruby19_build/ext/socket'
</code></pre>

There is no way to alias those just for Ruby? thinking that it could 
just provide the alternative after a failed LoadLibrary & GetAddressProc 
is missing reference?
Posted by Luis Lavena (Guest)
on 2010-10-13 01:44
(Received via mailing list)
Issue #3802 has been updated by Luis Lavena.


Sorry, I meant GetProcAddress (dislexia)

http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx
Posted by Usaku NAKAMURA (Guest)
on 2010-10-13 02:56
(Received via mailing list)
Issue #3802 has been updated by Usaku NAKAMURA.


There is no problem with VC.
So, this is a field of the maintainer of MinGW port.
If you want to be the maintainer of MinGW port, you have to solve
problems just like this by yourself.
Posted by Heesob Park (phasis)
on 2010-10-13 03:56
(Received via mailing list)
Hi,

2010/10/13 Usaku NAKAMURA <redmine@ruby-lang.org>:
> Issue #3802 has been updated by Usaku NAKAMURA.
>
>
> There is no problem with VC.
> So, this is a field of the maintainer of MinGW port.
> If you want to be the maintainer of MinGW port, you have to solve
> problems just like this by yourself.
>
Are you sure that there is no problem with VC?

When I try with ----enable-wide-getaddrinfo with VC9, it fails to make
like this:

compiling socket
        cl -nologo -I. -I../../.ext/include/i386-mswin32_90 
-I../.././include -I
../.././ext/socket -MD -Zi -W2 -wd4996 -O2sy-  -Zm600
-DRUBY_EXTCONF_H=\"extconf.h\" -I. -Foinit.obj -c -Tcinit.c init.c
c:\work\snapshot\ext\socket\addrinfo.h(175) : error C2373:
'freeaddrinfo' redefinition; different type modifiers.
        C:\Program Files\Microsoft
SDKs\Windows\v6.0A\include\ws2tcpip.h(414) : see declaration of
'freeaddrinfo'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
9.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '.\miniruby.exe' : return code '0x1'
Stop.

Here is a patch for VC.

--- addrinfo.h  2010-10-13 10:46:59.000000000 +0900
+++ addrinfo.h.new      2010-10-13 10:35:35.000000000 +0900
@@ -172,7 +172,7 @@
        int flags));

 extern void freehostent __P((struct hostent *));
-extern void freeaddrinfo __P((struct addrinfo *));
+extern void WSAAPI freeaddrinfo __P((struct addrinfo *));
 extern
 #ifdef GAI_STRERROR_CONST
 const


--- getaddrinfo.c       2010-10-13 10:46:59.000000000 +0900
+++ getaddrinfo.c.new   2010-10-13 10:35:30.000000000 +0900
@@ -207,7 +207,7 @@
 }
 #endif

-void
+void WSAAPI
 freeaddrinfo(struct addrinfo *ai)
 {
        struct addrinfo *next;
Posted by U.Nakamura (Guest)
on 2010-10-13 04:48
(Received via mailing list)
Hello,

In message "[ruby-core:32763] Re: [Ruby-Bug#3802] freeaddrinfo not found 
in WS2_32.dll"
    on Oct.13,2010 10:51:21, <phasis@gmail.com> wrote:
> > There is no problem with VC.
> >
> Are you sure that there is no problem with VC?

Ah, I want to say that "there is no problem with VC6".


> Here is a patch for VC.

Luis, how do you think this patch?


Regards,
Posted by Luis Lavena (luislavena)
on 2010-10-13 05:27
(Received via mailing list)
On Tue, Oct 12, 2010 at 11:44 PM, U.Nakamura <usa@garbagecollect.jp> 
wrote:
> Hello,
>
>> Here is a patch for VC.
>
> Luis, how do you think this patch?
>

While patch applies and solve the redefinition (good), it raises again
the broken IPv6 issue with undefined references:

<pre><code>
gcc -shared -s -o ../../.ext/i386-mingw32/socket.so init.o constants.o
basicsocket.o socket.o ipsocket.o tcpsocket.o tcpserver.o
sockssocket.o udpsocket.o unixsocket.o unixserver.o option.o ancdata.o
raddrinfo.o getaddrinfo.o getnameinfo.o
-L. -L../.. -L.  -Wl,--enable-auto-image-base,--enable-auto-import
socket-i386-mingw32.def  -lmsvcrt-ruby191 -lws2_32  -lshell32 -lws2_32
-limagehlp
getaddrinfo.o: In function `get_addr':
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:587:
undefined reference to `getipnodebyname'
getaddrinfo.o: In function `get_name':
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:543:
undefined reference to `getipnodebyaddr'
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:555:
undefined reference to `freehostent__compat'
getaddrinfo.o: In function `get_addr':
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:660:
undefined reference to `freehostent__compat'
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:590:
undefined reference to `getipnodebyname'
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:669:
undefined reference to `freehostent__compat'
getaddrinfo.o: In function `get_name':
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:564:
undefined reference to `freehostent__compat'
getnameinfo.o: In function `getnameinfo__compat':
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getnameinfo.c:227:
undefined reference to `getipnodebyaddr'
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getnameinfo.c:240:
undefined reference to `freehostent__compat'
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getnameinfo.c:246:
undefined reference to `freehostent__compat'
collect2: ld returned 1 exit status
</code></pre>

Which I think was solved in r24517:

http://redmine.ruby-lang.org/issues/show/1834

To quote your 3rd point in that ticket:

"(3) link errors with --enable-wide-getaddrinfo is ruby's bug."
Posted by Heesob Park (phasis)
on 2010-10-13 07:43
(Received via mailing list)
2010/10/13 Luis Lavena <luislavena@gmail.com>:
>
> undefined reference to `getipnodebyname'
> 
C:\Users\Luis\Projects\oss\oci\rubyinstaller\sandbox\ruby19_build\ext\socket/../../../../../../ruby/ext/socket/getaddrinfo.c:669:
> undefined reference to `freehostent__compat'
>
I can see the same error with VC9 with --enable-ipv6

It seems that getaddrinfo.c is not ready for Windows with ipv6 enabled.

The quick and simple way is disable ipv6 for Windows platform.

Here is a patch of ext/socket/extconf.rb

--- extconf.rb  2010-10-13 14:33:14.000000000 +0900
+++ extconf.rb.new      2010-10-13 14:34:41.000000000 +0900
@@ -34,7 +34,7 @@
 end

 ipv6 = false
-default_ipv6 = /mswin|cygwin|beos|haiku/ !~ RUBY_PLATFORM
+default_ipv6 = /mswin|mingw|cygwin|beos|haiku/ !~ RUBY_PLATFORM
 if enable_config("ipv6", default_ipv6)
   if checking_for("ipv6") {try_link(<<EOF)}
 #include <sys/types.h>
Posted by Luis Lavena (luislavena)
on 2010-10-13 20:10
(Received via mailing list)
On Wed, Oct 13, 2010 at 2:43 AM, Heesob Park <phasis@gmail.com> wrote:
>
> It seems that getaddrinfo.c is not ready for Windows with ipv6 enabled.
>

Well, ipv6 gets compiled and works when --enable-ipv6 is provided to
the configure process

(ext/socket/extconf.h)

#ifndef EXTCONF_H
#define EXTCONF_H
#define HAVE_SOCKETPAIR 1
#define ENABLE_IPV6 1
#define INET6 1
#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
#define HAVE_SOCKADDR_STORAGE 1
#define HAVE_SENDMSG 1
#define HAVE_RECVMSG 1
#define HAVE_TYPE_STRUCT_ADDRINFO 1
#define HAVE_FREEADDRINFO 1
#define HAVE_GAI_STRERROR 1
#define HAVE_GETNAMEINFO 1
#define HAVE_GETADDRINFO 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_TYPE_SOCKLEN_T 1
#define HAVE_TYPE_STRUCT_IN_PKTINFO 1
#define HAVE_TYPE_STRUCT_IN6_PKTINFO 1
#define HAVE_WSACLEANUP 1
#define HAVE_GETHOSTNAME 1
#endif


But combined with --enable-wide-getaddrinfo breaks.

So there is a compromise, either we loose IPv6 on newer OS or we keep
compatibility with old systems (Windows 2000).
Posted by Heesob Park (phasis)
on 2010-10-14 04:59
(Received via mailing list)
2010/10/14 Luis Lavena <luislavena@gmail.com>:
>
> So there is a compromise, either we loose IPv6 on newer OS or we keep
> compatibility with old systems (Windows 2000).

Another possible workaround is to provide modified ws2_32.dll with the
installer and it should be copied to the same directory where ruby.exe
is in.

Refer to 
http://codemagnet.blogspot.com/2007/10/winsock2-replacement.html

The dll source and binary link is
http://martin.brenner.de/files/winsock2_getaddrinfo.rar
Posted by Seth Goings (Guest)
on 2010-10-15 22:39
(Received via mailing list)
Issue #3802 has been updated by Seth Goings.


Heesob's solution seems to be the quickest and easiest workaround for 
now (for those using the RubyInstaller).
Posted by Luis Lavena (Guest)
on 2010-10-15 22:39
(Received via mailing list)
Issue #3802 has been updated by Luis Lavena.


Problem with that is add another layer to debug. It will not only 
require us track which version of Windows the user have, but also which 
version of winsock wrapper are we using.

It might be possible that having the same dll name trigger warnings from 
antivirus/spyware software.

Leaving that out for a second, there is a chance it will increase our 
support requirements (more time investigating what went wrong).

Going to see what we can do in our end without compromising IPV6 
support, perhaps dynamically load the function instead of compilation 
time.
Posted by Kathy F. (kathy_f)
on 2012-02-08 03:09
I'm new to Ruby, and user forums. I found this when searching for help
on a problem.

I downloaded from http://railsinstaller.org based on instructions from a
class I am taking. There were 2 choices during the install process. I
had the initial box checked to load Ruby, Git and the DevKit. We were
told not to select the configure option as we would not be using Git, so
the 2nd box was unchecked. I've been able to run an number of ruby
programs, but believe I am now having the problem documented in the
original post.

From a command window I typed "rails new lesson". After it indicated
"run bundle install" a window popped up stating that for ruby.exe "The
procedure entrypoint freeaddrinfo could not be located in the dynamic
link library WS2_32.dll." I am running Windows 2000, which appears to be
the problem. I'm wondering if there is any update or a solution to the
original post. The last post appears to be from over 2 years ago.

Thanks,
Kathy
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.