Wireshark-dev: [Wireshark-dev] Trouble properly building tshark-based PY extension

From: MARK LANDRISCINA <mlandri1@xxxxxxx>
Date: Tue, 29 Jul 2008 13:53:25 -0400
All:

I've written a C-based python extension module to dissect packets using wireshark's/tshark's dissection routines. The module has a function that reads packets sequentially from a capture file, dissects them, and then returns a python object containing all the data.

Works great with one exception. When I load a capture file I get a series of error messages (below) indicating that some of the plug-in modules could not be loaded.

I suspect that there is an error in my build routine, since the C-code works fine (no plug in module errors) when compiled and run as a C executable using wireshark's Makefile/build process. Also, I have to admit, I find wireshark's Makefile to be quite intimidating :)

I would greatly appreciate it if someone could take a look at the below errors and examine my build commands (also below) to see if there is a way to fix this problem.

Error messages:

Python 2.4.3 (#1, Oct  1 2006, 18:00:19) 
[GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sharklightPY import *
>>> cap_session = load_capturefile("sample_cap/local")
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/gryphon.so: /usr/local/lib/wireshark/plugins/1.0.0/gryphon.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/stats_tree.so: /usr/local/lib/wireshark/plugins/1.0.0/stats_tree.so: undefined symbol: stats_tree_manip_node
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/profinet.so: /usr/local/lib/wireshark/plugins/1.0.0/profinet.so: undefined symbol: dcom_hresult_vals
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/pcli.so: /usr/local/lib/wireshark/plugins/1.0.0/pcli.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/unistim.so: /usr/local/lib/wireshark/plugins/1.0.0/unistim.so: undefined symbol: register_tap
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/opsi.so: /usr/local/lib/wireshark/plugins/1.0.0/opsi.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/tango.so: /usr/local/lib/wireshark/plugins/1.0.0/tango.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/coseventcomm.so: /usr/local/lib/wireshark/plugins/1.0.0/coseventcomm.so: undefined symbol: register_giop_user_module
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/ethercat.so: /usr/local/lib/wireshark/plugins/1.0.0/ethercat.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/mate.so: /usr/local/lib/wireshark/plugins/1.0.0/mate.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/rtnet.so: /usr/local/lib/wireshark/plugins/1.0.0/rtnet.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/enttec.so: /usr/local/lib/wireshark/plugins/1.0.0/enttec.so: undefined symbol: proto_tree_add_none_format
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/sbus.so: /usr/local/lib/wireshark/plugins/1.0.0/sbus.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/cosnaming.so: /usr/local/lib/wireshark/plugins/1.0.0/cosnaming.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/rudp.so: /usr/local/lib/wireshark/plugins/1.0.0/rudp.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/agentx.so: /usr/local/lib/wireshark/plugins/1.0.0/agentx.so: undefined symbol: proto_tree_add_protocol_format
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/rlm.so: /usr/local/lib/wireshark/plugins/1.0.0/rlm.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/parlay.so: /usr/local/lib/wireshark/plugins/1.0.0/parlay.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/docsis.so: /usr/local/lib/wireshark/plugins/1.0.0/docsis.so: undefined symbol: proto_tree_add_protocol_format
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/m2m.so: /usr/local/lib/wireshark/plugins/1.0.0/m2m.so: undefined symbol: proto_tree_add_protocol_format
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/irda.so: /usr/local/lib/wireshark/plugins/1.0.0/irda.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/infiniband.so: /usr/local/lib/wireshark/plugins/1.0.0/infiniband.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/v5ua.so: /usr/local/lib/wireshark/plugins/1.0.0/v5ua.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/ciscosm.so: /usr/local/lib/wireshark/plugins/1.0.0/ciscosm.so: undefined symbol: proto_tree_add_item
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/wimaxasncp.so: /usr/local/lib/wireshark/plugins/1.0.0/wimaxasncp.so: undefined symbol: sminmpec_values
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/lwres.so: /usr/local/lib/wireshark/plugins/1.0.0/lwres.so: undefined symbol: tvb_get_nstringz
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/wimax.so: /usr/local/lib/wireshark/plugins/1.0.0/wimax.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/artnet.so: /usr/local/lib/wireshark/plugins/1.0.0/artnet.so: undefined symbol: proto_tree_add_none_format
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/asn1.so: /usr/local/lib/wireshark/plugins/1.0.0/asn1.so: undefined symbol: g_free
tshark: Couldn't load module /usr/local/lib/wireshark/plugins/1.0.0/opcua.so: /usr/local/lib/wireshark/plugins/1.0.0/opcua.so: undefined symbol: dissect_nt_64bit_time
>>> 


Build commands: (I get no errors/warnings during my build)

Step 1: make object files needed for dynamically loaded python module

>gcc -DHAVE_CONFIG_H -I. -I. -I.  -I. -I./wiretap    -I/usr/local/include  '-DPLUGIN_DIR="/usr/local/lib/wireshark/plugins/1.0.0"'  -DINET6 -D_U_="__attribute__((unused))" -g -O2 -Wall -W -Wdeclaration-after-statement -Wendif-labels -Wpointer-arith -Wno-pointer-sign -I/usr/local/include -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/python2.4 -I/usr/lib/python2.4 -fpic -c sharklightPY.c swig/sharklightPY_wrap.c

Step2: make dynamically loaded python module

>gcc -shared sharklightPY.o sharklightPY_wrap.o capture-pcap-util-unix.o capture-pcap-util.o cfile.o disabled_protos.o packet-range.o print.o ps.o timestats.o version_info.o .libs/sharklightPYS.o -Wl,--export-dynamic -L/usr/local/lib wiretap/.libs/libwiretap.so epan/.libs/libwireshark.so -lz -lpcre -L/lib -lgmodule-2.0 -lglib-2.0 -lm -lpcap -lkrb5 -lk5crypto -lcom_err -lresolv -ldl -lgcrypt -lgpg-error  -Wl,--rpath -Wl,/root/workspace/degen_pcap/wiretap/.libs -Wl,--rpath -Wl,/root/workspace/degen_pcap/epan/.libs -Wl,--rpath -Wl,/usr/local/lib -o _sharklightPY.so



Thanks in advance for your help.

Mark L.