[Win32utils-devel] if_indextoname on Windows?

Heesob Park phasis at gmail.com
Thu Aug 13 11:38:38 EDT 2009


Hi Dan,

2009/8/13 Daniel Berger <djberg96 at gmail.com>:
> Hi all,
>
> Windows Vista Home Premium
> VC++ 9
>
> According to MSDN, the if_indextoname() function should be included on
> Vista:
>
> http://msdn.microsoft.com/en-us/library/bb408408%28VS.85%29.aspx
>
> However, I can't get mkmf to see it. I tried all of these:
>
> require 'mkmf'
>
> if have_header('netioapi.h') # yes
>  have_func('if_indextoname', 'netioapi.h') # no
>  have_func('if_nametoindex', 'netioapi.h') # no
> end
>
> if have_header('iphlpapi.h') # yes
>  have_func('if_indextoname', 'iphlpapi.h') # no
>  have_func('if_nametoindex', 'iphlpapi.h') # no
> end
>
> have_library('iphlpapi') # yes
> have_library('iphlpapi', 'if_indextoname') # no
>
> What gives?
>
> BTW, this is in an effort to get dnssd to build on Windows.
>
Here is my result:

First, you must build ruby with --with-winsock2 option.

Second, WIN32_LEAN_AND_MEAN macro must not used.

C:\>irb
irb(main):001:0> require 'mkmf'
=> true
irb(main):002:0> COMMON_HEADERS.replace("#include <winsock2.h>")
=> "#include <winsock2.h>"
irb(main):003:0> have_header('netioapi.h')
checking for netioapi.h... yes
=> true
irb(main):004:0> have_func('if_indextoname', 'netioapi.h')
checking for if_indextoname() in netioapi.h... no
=> false
irb(main):005:0> have_func('if_indextoname', 'iphlpapi.h')
checking for if_indextoname() in iphlpapi.h... no
=> false
irb(main):006:0> have_library('iphlpapi', 'if_indextoname', 'netioapi.h')
checking for if_indextoname() in iphlpapi.lib... yes
=> true
irb(main):007:0> have_func('if_indextoname', 'netioapi.h')
checking for if_indextoname() in netioapi.h... yes
=> true
irb(main):008:0> have_func('if_nametoindex','netioapi.h')
checking for if_nametoindex() in netioapi.h... yes
=> true
irb(main):009:0> have_library('iphlpapi', 'if_nametoindex', 'netioapi.h')
checking for if_nametoindex() in iphlpapi.lib... yes
=> true


Regards,

Park Heesob


More information about the win32utils-devel mailing list