Here's where I am in making wiretap a DLL on win32.
I originally had problems because my instructions to build wiretap
as a DLL were causing a static version on the C library to be
linked into wiretap.dll, and another copy into tethereal.exe.
(I'm using tethereal as my test case since it's a bit
faster in compiling). I would not have noticed this except that
tethereal did not work. Wiretap.dll would create file descriptors and
pass them to tethereal.exe to use, but the file descriptors in
wiretap.dll were specific to the copy of the C library that wiretap.dll
held, and tethereal.exe would not honor those file descriptors.
I learned that the MSVC environment has 3 C libraries to link against:
LIBC.lib static, single-threaded
LIBCMT.lib static, multi-threaded
MSVCRT.dll dynamic, multi-threaded
(not to mention the debug versions of these)
Now I'm linking both wiretap.dll and tethereal.exe against msvcrt.dll,
the DLL version of the C library. That's all well and fine. They end
up sharing the same C library, and thus the same file descriptors.
However, I cannot link against libpcap.lib in this way. The objects in
libpcap.lib were compiled for use libcmt.lib, the static version of the
multi-threaded C library.
When I build a non-capturing version of tethereal.exe, without linking
with libpcap.lib, tethereal.exe works just fine (with wiretap.dll).
When I link tethereal.exe + libpcap.lib with no default
libraries, but do include msvcrt.lib, the linker complains about
unresolved symbols (_sys_nerr, from pcap.obj in libpcap.lib)
When I add LIBCMT.LIB to the link line, I get link errors regarding
multiple definitions of symbols (_exit, _mainCRTStartup, etc.)
Is there a way for me to link an executable using msvcrt.dll against
libpcap.lib, which contains objects compiled against LIBCMT.lib?
Or do I have to include the libpcap.lib sources from WPcapsrc in
the Ethereal distribution, convert the project file to a makefile, and
change the flags to either compile the objects in libpcap.lib against
msvcrt.dll, or do so *AND* make libpcap a DLL while I'm at it?
--gilbert