Wireshark-dev: Re: [Wireshark-dev] compile using libwireshark.dll

From: "Jonathan Walker (c)" <JWalker@xxxxxxxxxxxx>
Date: Fri, 12 Jun 2009 15:15:23 -0700

So, I decided to test this out and had everything working great.  My plug-in was compiling and working with other versions of Wireshark.  I moved my files to a different directory, and changed some of the Makefile.nmake to be able to locate my plugin source file from another directory, and the headers needed from other directories, and compiles just fine still.  However, now I’m getting a “no version symbol” error on Wireshark start-up.

 

Does anyone know why this is, or how to fix this error?

 

Thanks,

J. Walker

 


From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Bryant Eastham
Sent: Friday, June 12, 2009 11:01 AM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] compile using libwireshark.dll

 

I’m sure that others may not agree with this approach, but…

 

Although there are no guarantees of compatibility between versions, I have found that there are usually not problems. Using my method you could build the core of a version of Wireshark and send it to them. They could use the same method to compile your plugin, and then use the plugin with their (possibly different) version of Wireshark.

 

The thing that will cause problems is using a different version of compile tools. The ones that I use (in my scripts, below) is the version currently used to distribute Wireshark (1.2.0pre2), and so the plugins can be used with the “downloaded” Wireshark.

 

This would likely work if the versions were “close”. I found that even my 1.0.6 plugins ran with 1.2.0pre2, although I didn’t thoroughly test them.

 

From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Jonathan Walker (c)
Sent: Friday, June 12, 2009 9:44 AM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] compile using libwireshark.dll

 

I know there’s much more than libwireshark.lib that the compiler needs to compile the plugins (the headers, the glib libraries, makefiles, etc).  So, is there a way to supply all the NEEDED files for somebody else who (may be running a different version of WS but) would like to also compile my plug-in, without them having to download the source also?  So, maybe I could supply all the headers and glib files etc., and all they would have to do would be to change the libwireshark so that the versions of the plug-in and WS match up after the user compiles the plug-in?

 

After reading your response, I guess what I’m trying to do is not possible yet.   I’m just re-wording to make sure that if it really is a lost cause, at least I’m certain it isn’t possible.

 

Thank you,

J. Walker

 


From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Bryant Eastham
Sent: Friday, June 12, 2009 9:05 AM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] compile using libwireshark.dll

 

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