Wireshark-dev: Re: [Wireshark-dev] compile using libwireshark.dll
From: "Bryant Eastham" <beastham@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Jun 2009 08:05:09 -0600

Forgive the top-post and long response.

 

Unless things have changed, Wireshark does not directly support an “SDK” for plugins, or building them against anything but source. It is one of my pet-peeves, since plugins are all I ever produce. Since this may be useful for others, I can share what I do – it may highlight the difficulties and prompt the creation of an SDK, or somebody may correct my methods in ways that I have not seen.

 

First, I check my plugins into source control, putting them in a plugins directory just like I would if they were part of the Wireshark distribution. In that same directory I maintain my own Makefile.am and Makefile.nmake by copying the standard ones and then removing the standard plugins references and including my own. Other than those changes, my plugin source is equivalent to what it would be if it was included in the distribution.

 

Next, I download the Wireshark source code into a directory parallel to my plugins directory. In partial answer to your original question, there is much more than just a reference to the .lib file that is required to compile a plugin. Many (I would argue too many) of the Wireshark header files are required. Worse, there is no differentiation between “SDK” headers and “Standard” headers, so you really have to have access to all of them.

 

Finally, I have a set of custom support files that I have created that will “build” Wireshark and then “build” my plugins. I put these in another parallel directory called “build-tools”, and it goes into source control along with my plugins. I am willing to share them with whoever wants to see them, but many of them are specific to our build process (linux and cygwin). The main trick is to get Wireshark to build just what is needed to get a plugin to compile.

 

On Windows, I create the following batch file (meant to execute in the Wireshark directory):

 

call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"

@echo on

set MSVC_VARIANT=MSVC2008

nmake /e /f ..\build-tools\Makefile.nmake sdk

 

The referenced Makefile.nmake file is just:

 

include Makefile.nmake

 

sdk: setup config.h image wsutil $(ADNS_DLL) tshark.exe

 

This is really just a hack to add a target to the Wireshark Makefile. On Windows, building tshark is the best way to get things prepped to build plugins, however, I have found the dependencies of the Wireshark Makefile do not really support just building tshark and so the other dependencies need to be listed. This is one area where I think Wireshark could benefit plugin developers – by defining an SDK target in the Makefiles that just builds what you need to get the plugins to compile.

 

On Linux, things are a little better. The following script works for me although the path references likely make it unusable by others (meant to execute in the Wireshark directory):

 

#!/bin/bash

 

PATH=$PATH:/usr/local/bin

source /etc/profile.d/gtk2.sh

source /etc/profile.d/python.sh

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/opt/kde3/lib/pkgconfig:/opt/gnome/lib/pkgconfig:/opt/gnome/share/pkgconfig

 

./autogen.sh

./configure --disable-wireshark

make

 

Once this process is complete, you have what I would call an “SDK” of Wireshark. In fact, I archive the Wireshark directory at this point in our build system, and it only rebuilds if I change versions of Wireshark. Normally, I check out my plugins and then extract the previously built Wireshark into the same directory.

 

To build the plugins, I delete the Wireshark plugins directory and copy mine in its place. I then have a patchfile that I apply to configure.in, removing the standard plugins and putting in my own.

 

Then, on Windows, I execute the following in the Wireshark directory:

 

call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"

@echo on

set MSVC_VARIANT=MSVC2008

nmake /e /f ..\build-tools\Makefile.nmake plugins

if ERRORLEVEL 1 exit %ERRORLEVEL%

cd plugins

nmake /e /f Makefile.nmake install-plugins

exit %ERRORLEVEL%

 

On Linux:

 

#!/bin/bash

 

PATH=$PATH:/usr/local/bin

source /etc/profile.d/gtk2.sh

source /etc/profile.d/python.sh

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/opt/kde3/lib/pkgconfig:/opt/gnome/lib/pkgconfig:/opt/gnome/share/pkgconfig

 

cd wireshark/plugins

make

 

While a little convoluted, this process has shown to be fairly resilient to changes in Wireshark. In particular my patching of the configure.in file triggers an automatic reconfig of the source, but not a recompile. This process has meant that we can use continuous integration on our Wireshark plugins, with the compile times of just a few minutes to rebuild all 13 of our plugins on both Windows and Linux. That compares to almost 30 minutes to rebuild Wireshark.

 

This whole process would be much improved with just a few minor tweaks to the Wireshare files, but I have not gotten around to submitting anything.

 

Sorry for the long post. I know you didn’t ask for most of the detail, but based on your question I assume that you will run in to all of the issues that I have while  trying to do what you asked about.

 

-Bryant

 

From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Jonathan Walker (c)
Sent: Thursday, June 11, 2009 4:46 PM
To: wireshark-dev@xxxxxxxxxxxxx
Subject: [Wireshark-dev] compile using libwireshark.dll

 

Hello,

    I noticed that actual release versions of wireshark that can be downloaded online do not include a libwireshark.lib file, but they do include a libwireshark.dll.  Does this mean that the only possible way to compile a wireshark plugin is by compiling all of wireshark source first?  Or, is there a way to map the Makefile.nmake as follows:

 

LINK_PLUGIN_WITH=..\..\epan\libwireshark.dll

 

so that this may also work.  I’ve tried this, although it does not successfully compile my plugin.  Is there a way to do this?

 

Thank you,

J. Walker