linking with libbind

Stefan Puiu stefanpuiu at itcnetworks.ro
Fri Apr 16 08:29:46 UTC 2004


Thanks for enlightening me on these issues, only I don't see the 
similarity in the 8.2.x problems and those for 8.3.x and 8.4.x, since 
the first is a linkage problem, while the second involves include files. 
Or would the latter be solved by going into "port_*.h" files?

Anyway, I think I'll stick with libbind from 8.2.7 for now.

Danny Mayer wrote:

> The main problem you are having with the libbind 8.2.x version is that
> functions like strdup() which exist in the c library need to be defined
> in port_*.h (I forget which) with the extra underscore, while the res_*
> stuff need to be added into the libbind.def file, otherwise the library
> won't export the reference to them.
>
> With the 8.3.* and 8.4.* libbind's it's more complicated since you
> need to deal with the IPv6 pieces. It's similar to the above, just more
> work.
>
> Danny
>
> At 07:29 AM 4/15/2004, Stefan Puiu wrote:
>
>> 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