Question

I am attempting to compile a program against libwireshark on Ubuntu 10.10. I have installed the wireshark-dev package, which has installed files in /usr/lib/wireshark and /usr/include/wireshark.

The head of my C source code file contains a #include <epan/epan.h> directive and my gcc command line arguments are as follows:

$ gcc -I/usr/include/wireshark `pkg-config --libs --cflags glib-2.0` -Wall -o test.out test.c -L/usr/lib/wireshark -lwireshark

However, this returns many errors, including:

/usr/lib/gcc/i686-linux-gnu/4.4.5/include/varargs.h:4: error: #error "GCC no longer implements <varargs.h>."
/usr/include/wireshark/epan/ftypes/ftypes.h:258: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘union’

What should I do to rectify these issues?

Was it helpful?

Solution

It seems a simple case of user-unfriendly packaging and code organization. You need to include the "config" header for Wireshark first. I would write it this way:

#include <wireshark/config.h> /* needed by epan */
#include <epan/epan.h>

Be sure that you do this first whenever you include headers from this library.

How did I know? I dug into epan/proto.h and found that it conditionally includes varargs.h only if HAVE_STDARG is not set. I then grep'd in /usr/include/wireshark/ and found this variable is set in config.h, so I figured it might be necessary to include it, and lo, it was.

I also needed to add -lwiretap to satisfy linkage with libwireshark.

Another nit in the organization of wireshark-dev is that it does not depend (at the package level) on wireshark-common, even though the latter does provide the actual libwireshark.so which the former symlinks to. So you should make sure that wireshark-common is installed, or that /usr/lib/libwireshark.so and its referent exist.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top