0

I want to use TShark source files to dissect a message (e.g rrc sib 3 message) in C++. I have done the following steps:

  1. Download wireshark-2.6.6.tar.xz and go to the extracted folder.
  2. sudo ./configure --prefix=/home/***/build/
  3. sudo make -j 8
  4. sudo make install (After that I have a build folder which is contains bin, include, lib, share folders.)
  5. Open C++ ide (Qt) and add the following libs:

     LIBS += -L/home/***/build/lib/ -lwireshark \
            -L/home/***/build/lib/ -lwiretap \
            -L/home/***/build/lib/ -lwsutil \
            -L/home/***/build/lib/ -lwscodecs
    
  6. Of course I include the path like this:

     INCLUDEPATH += /home/***/build/include/wireshark
     DEPENDPATH += /home/***/build/include/wireshark
    
  7. And also the wireshark source folder which I downloaded in step 1:

    INCLUDEPATH += /home/***/wireshark-2.6.6
    DEPENDPATH += /home/***/wireshark-2.6.6
    
  8. Open TShark.c file (/home/***/wireshark-2.6.6/tshark.c) in Qt.

After these steps, it seems that every thing should be OK, but I have undefined reference to about 70 functions that I think I should add some other libs in step 5.

A part of my code (tshark.c) is as follows:

...
...
...
static int
real_main(int argc, char *argv[])
{
   ...
   initialize_funnel_ops();
   return exit_status;
}
int
main(int argc, char *argv[])
{
   return real_main(argc, argv);
}
...
...
...

The initialize_funnel_ops() function which is in /build/include/wireshark/epan/funnel.h gives this error:

error: undefined reference to `initialize_funnel_ops'

This error apears for some other funtions too.

So how can I solve it? Should I add a new library? Or did I make a mistake in adding the libraries and the path?

  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Werner Henze Feb 25 '19 at 08:07
  • Try to link with *libtshark.so* library, too. If the library does not exist, try to add the option *--enable-tshark* to *configure*. – Dimitry Ernot Feb 25 '19 at 08:36
  • @WernerHenze thanks, I know the reason of this error. I think I need another libraries and the link which you specified does not solve my problem. – ahmadi morteza ali Feb 25 '19 at 09:03
  • @RomhaKorev thank you very much, but after configuring with --enable-tshark, no library was created and I could not add it to my program. Do you know why not creating it? – ahmadi morteza ali Feb 25 '19 at 09:06
  • @RomhaKorev --enable-tshark is set by default. – ahmadi morteza ali Feb 25 '19 at 13:51

1 Answers1

1

The top-level Wireshark CMakeLists.txt file should help you figure out what libraries and files tshark needs. One of the dependencies is ${TSHARK_TAP_SRC}, which includes ${CMAKE_SOURCE_DIR}/ui/cli/tap-funnel.c, and tap-funnel.c is the file where initialize_funnel_ops() is defined.

Christopher Maynard
  • 5,702
  • 2
  • 17
  • 23
  • Thanks, after adding `#include ` the error for that function was solved. Is it a right way to include c files in my code to solve all of the similar errors? – ahmadi morteza ali Feb 25 '19 at 16:38
  • That's not really the right way to compile multiple source files into 1 binary. Have a look at your compiler's manual, man pages for more information about how to do this, but as a quick example assuming gcc is your compiler, you might use `gcc file1.c file2.c ... fileN.c -o myprogram`. This doesn't really scale very well though, so normally Makefiles are used to help with this. But since Wireshark uses cmake now, you might also want to look into using that. – Christopher Maynard Feb 25 '19 at 18:52