Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linking problems with BIND8's libbind on Windows.

30 views
Skip to first unread message

Sudhir Mohith

unread,
Aug 25, 2003, 2:54:16 PM8/25/03
to

Hello,

I am using the BIND 8.4.1 libbind code as part of a naming service project
on Windows (I'm using Visual Studio 6.0). The primary routines I need are
res_init() and res_query(). I started by building the entire BIND tree
which completed fine and it built the libbind.dll, libbind.lib,
libbind.exp, libbind.map, etc.

Now to get my code to compile, I needed to struggle a little and figured
out that I didn't need to #include resolv.h and netdb.h but could just
#include Windows' windows.h and BIND's binwsock.h and that compiled ok.
However, I am currently having problems when linking my code with the
libbind library as per:

link.exe /DEBUGTYPE:CV /NODEFAULTLIB -debug:full -debugtype:cv
/NODEFAULTLIB /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO
-subsystem:console,4.0 /out:..\obj\winnt\tests\test.exe
..\obj\winnt\file1.obj ..\obj\winnt\file2.obj ..\obj\winnt\file3.obj
libbind.lib msvcrt.lib oldnames.lib kernel32.lib ws2_32.lib mswsock.lib
advapi32.lib
file2.obj : error LNK2001: unresolved external symbol _res_init@0
file2.obj : error LNK2001: unresolved external symbol _res_query@20
..\obj\winnt\tests\test.exe : fatal error LNK1120: 2 unresolved externals

Now when I do a dumpbin /exports on the libbind.lib that was produced in my
Release directory as part of the BIND build (and which I am linking with
above), I do not see the __res_init and __res_query symbols there. However,
if I run a dumpbin /exports on the libbind.dll that was created at BIND
build time, then those symbols are there.

So my question is - can I get my application to build with the static
libbind.lib by rebuilding the library with some other option (which will
include those missing symbols in the *.lib file) or do I need to use the
libbind.dll to link with my application and if so how would I go about
doing that.

Thanks, Sudhir


Danny Mayer

unread,
Aug 25, 2003, 10:26:33 PM8/25/03
to

Check libbind.def for the files. __res_init is defined there. __res_query
is not, at least in 8.3.4 which is the last BIND 8 I built. For some reason
you don't have an extra underscore ("_") in your file2.c. Make sure you
are using STDC (standard C). You will probably need to add at least
__res_query to libbind.def.

Danny

Sudhir Mohith

unread,
Aug 26, 2003, 12:58:22 PM8/26/03
to

In <biegp0$gqh$1...@sf1.isc.org>, Danny Mayer (ma...@gis.net) wrote:

%s> >However, I am currently having problems when linking my code with the
%s> >libbind library as per:
%s> >
%s> > link.exe /DEBUGTYPE:CV /NODEFAULTLIB -debug:full -debugtype:cv
%s> >/NODEFAULTLIB /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO
%s> >-subsystem:console,4.0 /out:..\obj\winnt\tests\test.exe
%s> >..\obj\winnt\file1.obj ..\obj\winnt\file2.obj ..\obj\winnt\file3.obj
%s> >libbind.lib msvcrt.lib oldnames.lib kernel32.lib ws2_32.lib
mswsock.lib
%s> >advapi32.lib
%s> >file2.obj : error LNK2001: unresolved external symbol _res_init@0
%s> >file2.obj : error LNK2001: unresolved external symbol _res_query@20
%s> >..\obj\winnt\tests\test.exe : fatal error LNK1120: 2 unresolved
externals

%s> Check libbind.def for the files. __res_init is defined there.
__res_query
%s> is not, at least in 8.3.4 which is the last BIND 8 I built. For some
reason
%s> you don't have an extra underscore ("_") in your file2.c. Make sure you
%s> are using STDC (standard C). You will probably need to add at least
%s> __res_query to libbind.def.

I changed all calls to res_init() and res_query in my file2.c to
_res_init()
and _res_query and the linking is still failing with the same errors. I
have the feeling I am not invoking the link.exe above with the correct
arguments.

The libbind.lib I am using to link is the one I built from the BIND tree
and
which ended up in port/winnt/libbind/Release. I copied that file across to
a
directory which is in my $LIB path. After that failed, I modified the
libbind.def file
in port/winnt/libbind and passed it as /def:libbind.def to link.exe and
that
failed with a larger number of unresolved symbols for symbold defined in
the *.def file
but not in the *.lib file.

What I would have liked to know is that my test.exe depends on file1.c,
file2.c, file3.c, a couple of system libraries and libbind. So how would I
need to modify my Makefile to import the routines from the libbind I built
from the BIND tree? Do I need to use the DLL directly or do I need to pass
a
specific flag to the linker to use the LIB and DEF files and any other
files I
may need.

In other words let's say you wrote some simple code that calls _res_init()
and
_res_query() in my_test.c and you want to link my_test.c with the libbind
libraries that you built separately from the BIND8 distribution (i.e the
port/winnt/libbind) to create my_test.exe, how would you do that in VC++
6.0?

Thanks, Sudhir


0 new messages