Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] Using cf_callback_add from a plugin

From: "Bruce, Joseph R (Joe)" <joseph.bruce@xxxxxxx>
Date: Fri, 22 Apr 2011 15:05:40 -0700
Hi,

I'm writing a plugin that registers a capture file callback via
cf_callback_add (./file.c:173, ./file.h:83).  The callback is invoked on
read and other interesting cf events.  This works fine on my *nix build,
but Windows is unhappy.  The only other code that registers a cf callback
is ./gtk/main.c, which Windows has no problem with.  My plugin fails to
link with unresolved symbol errors:

 
        link -dll /out:vulcan.dll /NOLOGO /INCREMENTAL:no /DEBUG
/MACHINE:x86 /SafeSEH /DYNAMICBASE /FIXED:no  packet-vulcan.obj
vulcan_utils.obj plugin.obj ..\..\epan\libwireshark.lib
..\..\wsutil\libwsutil.lib  C:\wireshark-win32-libs\gtk2\lib\glib-2.0.lib
C:\wireshark-win32-libs\gtk2\lib\gmodule-2.0.lib
C:\wireshark-win32-libs\gtk2\lib\gobject-2.0.lib vulcan.res
   Creating library vulcan.lib and object vulcan.exp
packet-vulcan.obj : error LNK2019: unresolved external symbol
_cf_callback_add referenced in function _proto_register_vulcan
vulcan.dll : fatal error LNK1120: 1 unresolved externals


So one question I can't answer is why this works on the *nix side, and not
the Windows side.

I also can't answer why gtk (when building and linking libui.lib) succeeds
and my plugin fails to resolve cf_callback_add.

Finally, and this is most confusing to me, file.c is not even compiled
until wireshark.exe is built, which is much later in the build process
than my plugin and libui.  How does that work?

I'm sure I'm missing some fundamental understanding of the Windows build
process.  I'd appreciate it if someone could explain it to me.

Thanks,
Joe