ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] HELP: about tshark shared library.

From: Pankaj Yadav <p.yadav@xxxxxxxxxxx>
Date: Tue, 25 Mar 2008 16:14:43 +0530 (IST)
Hi All,

I want to create a shared library for tshark (using wireshark-0.99.8).
For that, i copied tshark.c as libtshark.c[where i change main() to tshark()] then i add tshark.c [whre i called tshark()] and added tshrk.h

Then I did:
(1) object file for libtshark.c as:
/bin/sh /usr/bin/libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.. -I./../.. -I./..    -I/usr/local/include  '-DPLUGIN_DIR="/usr/local/lib/wireshark/plugins/0.99.8"'  -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    -MT libcleandissectors_la-libtshark.lo -MD -MP -MF .deps/libcleandissectors_la-libtshark.Tpo -c -o libcleandissectors_la-libtshark.lo `test -f 'libtshark.c' || echo './'`libtshark.c

 gcc -DHAVE_CONFIG_H -I. -I../.. -I./../.. -I./.. -I/usr/local/include -DPLUGIN_DIR=\"/usr/local/lib/wireshark/plugins/0.99.8\" -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 -MT libcleandissectors_la-libtshark.lo -MD -MP -MF .deps/libcleandissectors_la-libtshark.Tpo -c libtshark.c  -fPIC -DPIC -o libtshark.o

(2) created libtshark.so.0.0 file as:
gcc -shared -g -Wl,-soname,libtshark.so.0 -o libtshark.so.0.0 libtshark.o -lc

(3) ldconfig as:
ldconfig -n .

(4) symbolic link as:
 ln -sf libtshark.so.0 libtshark.so

(5) Object file for tshark.c as:
/bin/sh /usr/bin/libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.. -I./../.. -I./..    -I/usr/local/include  '-DPLUGIN_DIR="/usr/local/lib/wireshark/plugins/0.99.8"'  -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    -MT libcleandissectors_la-tshark.lo -MD -MP -MF .deps/libcleandissectors_la-tshark.Tpo -c -o libcleandissectors_la-tshark.lo `test -f 'tshark.c' || echo './'`tshark.c

 gcc -DHAVE_CONFIG_H -I. -I../.. -I./../.. -I./.. -I/usr/local/include -DPLUGIN_DIR=\"/usr/local/lib/wireshark/plugins/0.99.8\" -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 -MT libcleandissectors_la-tshark.lo -MD -MP -MF .deps/libcleandissectors_la-tshark.Tpo -c tshark.c  -fPIC -DPIC -o tshark.o

(6) Final Compilation
gcc -DHAVE_CONFIG_H -I. -I../.. -I./../.. -I./.. -I/usr/local/include -DPLUGIN_DIR=\"/usr/local/lib/wireshark/plugins/0.99.8\" -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 -MT libcleandissectors_la-tshark.lo -MD -MP -MF .deps/libcleandissectors_la-tshark.Tpo -o tshark tshark.o -L. -ltshark


It will gives errors as:
./libtshark.so: undefined reference to `get_column_format'
./libtshark.so: undefined reference to `host_name_lookup_process'
./libtshark.so: undefined reference to `set_disabled_protos_list'
./libtshark.so: undefined reference to `g_free'
./libtshark.so: undefined reference to `string_to_name_resolve'
./libtshark.so: undefined reference to `sync_pipe_start'
./libtshark.so: undefined reference to `capture_opts_list_interfaces'
./libtshark.so: undefined reference to `init_cap_file'
./libtshark.so: undefined reference to `proto_tree_write_psml'
./libtshark.so: undefined reference to `have_tap_listeners'
./libtshark.so: undefined reference to `dissector_change'
./libtshark.so: undefined reference to `g_slist_free'
./libtshark.so: undefined reference to `ex_opt_add'
./libtshark.so: undefined reference to `list_stat_cmd_args'
./libtshark.so: undefined reference to `dfilter_free'
./libtshark.so: undefined reference to `get_cur_groupname'
./libtshark.so: undefined reference to `pcap_close'
./libtshark.so: undefined reference to `register_all_protocols'
./libtshark.so: undefined reference to `wtap_snapshot_length'
./libtshark.so: undefined reference to `wtap_strerror'
./libtshark.so: undefined reference to `read_disabled_protos_list'
./libtshark.so: undefined reference to `nstime_set_unset'
./libtshark.so: undefined reference to `g_strdup'
./libtshark.so: undefined reference to `output_fields_new'
./libtshark.so: undefined reference to `prefs_set_pref'
./libtshark.so: undefined reference to `capture_opts_trim_snaplen'
./libtshark.so: undefined reference to `timestamp_set_precision'
./libtshark.so: undefined reference to `started_with_special_privs'
./libtshark.so: undefined reference to `proto_registrar_dump_protocols'
./libtshark.so: undefined reference to `get_column_format_matches'
./libtshark.so: undefined reference to `g_malloc'
./libtshark.so: undefined reference to `register_all_plugin_tap_listeners'
./libtshark.so: undefined reference to `dfilter_apply_edt'
./libtshark.so: undefined reference to `init_dissection'
./libtshark.so: undefined reference to `prefs_register_modules'
./libtshark.so: undefined reference to `g_string_new'
./libtshark.so: undefined reference to `wtap_dump_close'
./libtshark.so: undefined reference to `funnel_dump_all_text_windows'
./libtshark.so: undefined reference to `sync_pipe_stop'
./libtshark.so: undefined reference to `get_compiled_version_info'
./libtshark.so: undefined reference to `epan_dissect_free'
./libtshark.so: undefined reference to `dfilter_error_msg'
./libtshark.so: undefined reference to `pcap_compile'
./libtshark.so: undefined reference to `dissector_handle_get_protocol_index'
./libtshark.so: undefined reference to `wtap_file_type_string'
./libtshark.so: undefined reference to `wtap_file_type'
./libtshark.so: undefined reference to `nstime_delta'
./libtshark.so: undefined reference to `proto_tree_write_pdml'
./libtshark.so: undefined reference to `process_stat_cmd_arg'
./libtshark.so: undefined reference to `capture_opts_init'
./libtshark.so: undefined reference to `g_strdup_printf'
./libtshark.so: undefined reference to `epan_dissect_prime_dfilter'
./libtshark.so: undefined reference to `print_hex_data'
./libtshark.so: undefined reference to `register_all_tap_listeners'
./libtshark.so: undefined reference to `wtap_buf_ptr'
./libtshark.so: undefined reference to `output_fields_num_fields'
./libtshark.so: undefined reference to `get_dissector_table_selector_type'
./libtshark.so: undefined reference to `timestamp_set_type'
./libtshark.so: undefined reference to `wtap_get_num_file_types'
./libtshark.so: undefined reference to `register_all_protocol_handoffs'
./libtshark.so: undefined reference to `get_cur_username'
./libtshark.so: undefined reference to `running_with_special_privs'
./libtshark.so: undefined reference to `output_fields_free'
./libtshark.so: undefined reference to `get_column_title'
./libtshark.so: undefined reference to `set_profile_name'
./libtshark.so: undefined reference to `g_snprintf'
./libtshark.so: undefined reference to `nstime_is_unset'
./libtshark.so: undefined reference to `get_credential_info'
./libtshark.so: undefined reference to `capture_opts_list_link_layer_types'
./libtshark.so: undefined reference to `profile_exists'
./libtshark.so: undefined reference to `init_progfile_dir'
./libtshark.so: undefined reference to `col_setup'
./libtshark.so: undefined reference to `print_finale'
./libtshark.so: undefined reference to `tap_push_tapped_queue'
./libtshark.so: undefined reference to `output_fields_set_option'
./libtshark.so: undefined reference to `wireshark_svnversion'
./libtshark.so: undefined reference to `write_prefs'
./libtshark.so: undefined reference to `epan_dissect_fill_in_columns'
./libtshark.so: undefined reference to `dissector_table_foreach_handle'
./libtshark.so: undefined reference to `g_assert_warning'
./libtshark.so: undefined reference to `read_prefs'
./libtshark.so: undefined reference to `wtap_read'
./libtshark.so: undefined reference to `relinquish_special_privs_perm'
./libtshark.so: undefined reference to `write_pdml_preamble'
./libtshark.so: undefined reference to `wtap_dump_can_open'
./libtshark.so: undefined reference to `proto_tree_write_fields'
./libtshark.so: undefined reference to `get_epan_compiled_version_info'
./libtshark.so: undefined reference to `wtap_close'
./libtshark.so: undefined reference to `epan_cleanup'
./libtshark.so: undefined reference to `g_realloc'
./libtshark.so: undefined reference to `draw_tap_listeners'
./libtshark.so: undefined reference to `print_preamble'
./libtshark.so: undefined reference to `write_fields_finale'
./libtshark.so: undefined reference to `write_psml_finale'
./libtshark.so: undefined reference to `write_pdml_finale'
./libtshark.so: undefined reference to `wtap_file_tsprecision'
./libtshark.so: undefined reference to `pcap_open_dead'
./libtshark.so: undefined reference to `wtap_file_type_short_string'
./libtshark.so: undefined reference to `write_fields_preamble'
./libtshark.so: undefined reference to `proto_get_id_by_filter_name'
./libtshark.so: undefined reference to `find_dissector_table'
./libtshark.so: undefined reference to `print_stream_text_stdio_new'
./libtshark.so: undefined reference to `packet_range_init'
./libtshark.so: undefined reference to `nstime_set_zero'
./libtshark.so: undefined reference to `capture_opts_add_opt'
./libtshark.so: undefined reference to `wtap_open_offline'
./libtshark.so: undefined reference to `g_log_set_handler'
./libtshark.so: undefined reference to `output_fields_list_options'
./libtshark.so: undefined reference to `g_resolv_flags'
./libtshark.so: undefined reference to `initialize_funnel_ops'
./libtshark.so: undefined reference to `proto_tree_print'
./libtshark.so: undefined reference to `g_malloc0'
./libtshark.so: undefined reference to `get_if_name'
./libtshark.so: undefined reference to `proto_get_protocol_name'
./libtshark.so: undefined reference to `epan_init'
./libtshark.so: undefined reference to `dissector_dump_decodes'
./libtshark.so: undefined reference to `proto_registrar_dump_fields'
./libtshark.so: undefined reference to `print_line'
./libtshark.so: undefined reference to `wtap_pseudoheader'
./libtshark.so: undefined reference to `prefs_apply_all'
./libtshark.so: undefined reference to `wtap_phdr'
./libtshark.so: undefined reference to `wtap_dump'
./libtshark.so: undefined reference to `tap_queue_init'
./libtshark.so: undefined reference to `dissector_change_string'
./libtshark.so: undefined reference to `dissector_all_tables_foreach_table'
./libtshark.so: undefined reference to `print_stream_ps_stdio_new'
./libtshark.so: undefined reference to `output_fields_add'
./libtshark.so: undefined reference to `wtap_file_encap'
./libtshark.so: undefined reference to `proto_registrar_dump_values'
./libtshark.so: undefined reference to `wtap_short_string_to_file_type'
./libtshark.so: undefined reference to `epan_dissect_new'
./libtshark.so: undefined reference to `num_tap_filters'
./libtshark.so: undefined reference to `write_psml_preamble'
./libtshark.so: undefined reference to `wtap_dump_open'
./libtshark.so: undefined reference to `capture_opts_trim_ring_num_files'
./libtshark.so: undefined reference to `capture_opts_trim_iface'
./libtshark.so: undefined reference to `g_log'
./libtshark.so: undefined reference to `get_runtime_version_info'
./libtshark.so: undefined reference to `get_copyright_info'
./libtshark.so: undefined reference to `get_interface_descriptive_name'
./libtshark.so: undefined reference to `get_args_as_string'
./libtshark.so: undefined reference to `file_open_error_message'
./libtshark.so: undefined reference to `proto_get_protocol_filter_name'
./libtshark.so: undefined reference to `epan_dissect_run'
./libtshark.so: undefined reference to `dfilter_compile'
./libtshark.so: undefined reference to `start_requested_stats'
collect2: ld returned 1 exit status


Please HELP me on this...

Thanks in advance,
Pankaj.



Save all your chat conversations. Find them online.