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?
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:
Be sure that you do this first whenever you include headers from this library.
How did I know? I dug into
epan/proto.hand found that it conditionally includesvarargs.honly ifHAVE_STDARGis not set. I thengrep‘d in/usr/include/wireshark/and found this variable is set inconfig.h, so I figured it might be necessary to include it, and lo, it was.I also needed to add
-lwiretapto satisfy linkage withlibwireshark.Another nit in the organization of
wireshark-devis that it does not depend (at the package level) onwireshark-common, even though the latter does provide the actuallibwireshark.sowhich the former symlinks to. So you should make sure thatwireshark-commonis installed, or that/usr/lib/libwireshark.soand its referent exist.