linking with libbind

Stefan Puiu stefanpuiu at itcnetworks.ro
Thu Apr 15 11:29:13 UTC 2004


Hello list,
I'm having quite some trouble building a static library that uses 
BIND8's libbind (I've tried several BIND8 versions, see below) on 
Windows 2000, using Microsoft's VC++ 6.0's compiler. There are two 
distinct issues:

1) In my main header file I'm including one of our internal header 
files, then I have:

#include <arpa/nameser.h>
#include <resolv.h>
#include <res_update.h>

Basically I'm using the res_ninit, res_nclose, res_mkupdrec and 
res_nupdate functions. If I put the include and port/winnt/include 
directories from BIND 8.4.4 in my include directories, I get the strange 
errors from attachment 1, the highlight being some redefined symbols 
(p_gethostname, p_gethostbyname, etc.) in 
\port\winnt\include\sys\socket.h. After a bit of tweaking, they are the 
only errors left. I've tried older BIND 8 versions, and it seems all 
versions from 8.3.0 have this strange problem.

2) On the other hand, BIND 8.2.7 is the latest version that doesn't show 
this strange error, so I decided I'd use it, and my library compiles ok, 
but when trying to link a binary to my library and libbind I get this 
error about unresolved symbols

mylib.lib(MyFile.obj) : error LNK2001: unresolved external symbol "void 
__cdecl __res_freeupdrec(struct ns_updrec *)" 
(?__res_freeupdrec@@YAXPAUns_updrec@@@Z)
mylib.lib(MyFile.obj) : error LNK2001: unresolved external symbol "void 
(__cdecl* __assertion_failed)(char *,int,enum assertion_type,char 
*,int)" (?__assertion_failed@@3P6AXPADHW4assertion_type@@0H at ZA)
mylib.lib(MyFile.obj) : error LNK2001: unresolved external symbol 
"struct ns_updrec * __cdecl __res_mkupdrec(int,char const *,unsigned 
int,unsigned int,unsigned long)" 
(?__res_mkupdrec@@YAPAUns_updrec@@HPBDIIK at Z)
mylib.lib(MyFile.obj) : error LNK2001: unresolved external symbol 
__imp___strdup
mylib.lib(MyFile.obj) : error LNK2001: unresolved external symbol 
___res_nclose
mylib.lib(MyFile.obj) : error LNK2001: unresolved external symbol "int 
__cdecl __res_nupdate(struct __res_state *,struct ns_updrec *,struct 
ns_tsig_key *)" 
(?__res_nupdate@@YAHPAU__res_state@@PAUns_updrec@@PAUns_tsig_key@@@Z):

I looked with dumpbin /exports in libbind.lib and noticed that all these 
functions exist, but their name begins with three underscores (___) 
instead of two (__). Is there some way I can convince the linker into 
properly linking the binary? Or should I be using a different BIND 
version? I'm trying to link against the lib file in 
port\winnt\libbind\Debug, and am also linking with msvcrtd.lib (debug 
multithreaded). I've built libbind from 8.2.7 using nmake from the 
command line, since the libbind.dsp file seems to be broken, using nmake 
/f named.mak CFG=Debug (under port\winnt).

Other compile options I'm using (pasted in from VC++):

/nologo /MDd /W4 /Gm /GX /ZI /Od /I <list of include dirs> /GZ, and I 
also have the WIN32, _DEBUG, _MBCS, _LIB, i386 constants defined. I'm 
not using precompiled headers.

Any help is greatly appreciated.


-- Attached file included as plaintext by Ecartis --
-- File: libbind-8.4.4.err

c:\src\bind\bind-8.4.4\src\port\winnt\include\port_after.h(172) : error C2201: 'isc_in6addr_any' : must have external linkage in order to be exported/imported
c:\src\bind\bind-8.4.4\src\port\winnt\include\port_after.h(172) : warning C4268: 'isc_in6addr_any' : 'const' static/global data initialized with compiler generated default constructor fills the object with zeros
c:\src\bind\bind-8.4.4\src\port\winnt\include\port_after.h(173) : error C2201: 'isc_in6addr_loopback' : must have external linkage in order to be exported/imported
c:\src\bind\bind-8.4.4\src\port\winnt\include\port_after.h(173) : warning C4268: 'isc_in6addr_loopback' : 'const' static/global data initialized with compiler generated default constructor fills the object with zeros
c:\src\bind\bind-8.4.4\src\port\winnt\include\sys\socket.h(60) : error C2086: 'p_gethostbyaddr' : redefinition
c:\src\bind\bind-8.4.4\src\port\winnt\include\sys\socket.h(61) : error C2086: 'p_gethostbyname' : redefinition
c:\src\bind\bind-8.4.4\src\port\winnt\include\sys\socket.h(62) : error C2086: 'p_gethostname' : redefinition
c:\src\bind\bind-8.4.4\src\port\winnt\include\sys\socket.h(63) : error C2086: 'p_getprotobyname' : redefinition
c:\src\bind\bind-8.4.4\src\port\winnt\include\sys\socket.h(64) : error C2086: 'p_getprotobynumber' : redefinition
c:\src\bind\bind-8.4.4\src\port\winnt\include\sys\socket.h(65) : error C2086: 'p_getservbyname' : redefinition
c:\src\bind\bind-8.4.4\src\port\winnt\include\sys\socket.h(66) : error C2086: 'p_getservbyport' : redefinition



More information about the bind-users mailing list