This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Tshark and Dissector are in the same project when compiling?

0

Hi all, I'm using both of tshark.c and dissector "packet-camel.c". i wonder when gcc compiles tshark and Dissector, does it consider them as in the same project? Because when I try to use an extern variable for both of these files, the variable in different files are different. i think that the tshark.c call dissector to do something so that it doesn't make sense if an extern variable in tshark.c has different value when it is called in dissector "packet-camel.c". Thanks for your help.

asked 02 Oct '13, 02:02

hoangsonk49's gravatar image

hoangsonk49
81282933
accept rate: 28%


One Answer:

2

tshark.c is compiled as part of tshark, packet-camel.c is compiled as part of libwireshark which is linked to by tshark.

The variable will have to be declared and exported from one part and then extern'd from the other part. I would suggest that it would be best to be declared and exported from libwireshark and then extern'd in tshark as tshark has a dependency on libwireshark and not the other way around.

Note that to export symbols in a cross platform manner some hoops have to be jumped through, look at ws_export_symbol.h in the top level directory and the use of WS_DLL_PUBLIC elsewhere in the source code.

answered 02 Oct '13, 02:38

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

edited 02 Oct '13, 03:27

Problem solved. Thanks for your idea, grahamb :-)

(02 Oct '13, 02:49) hoangsonk49

Hint: If a supplied answer resolves your question can you please "accept" it by clicking the checkmark icon next to it. This highlights good answers for the benefit of subsequent users with the same or similar questions

(02 Oct '13, 04:41) Kurt Knochner ♦