66

I am trying to compile a C++ program like this:

$ g++ -o Sniffer_Train main.cpp Sniffer_train.cpp Sniffer_train.h -lmysqlclient -lpcap

However I get the following error:

/usr/bin/ld: /tmp/cct6xeXD.o: undefined reference to symbol
'pthread_join@@GLIBC_2.4' //lib/arm-linux-gnueabihf/libpthread.so.0:
error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

I have no idea what this error means. Any help will be greatly appreciated.

Oxfist
  • 613
  • 5
  • 18
srai
  • 953
  • 2
  • 13
  • 23

1 Answers1

102

DSO here means Dynamic Shared Object; since the error message says it's missing from the command line, I guess you have to add it to the command line.

That is, try adding -lpthread to your command line.

anatolyg
  • 23,079
  • 7
  • 51
  • 113
  • Thanks, I had a similar problem with some other project and was able to solve it this way. I just want to add that now that I looked closer I can see that the error is actually very unambigious on what the problem is. I mean, it does say that `pthread_join` is undefined and that it belongs to `libpthread.so`. But like srai I had no idea what the error meant until I came here. :-) – Alex Jul 02 '15 at 11:41
  • 5
    Does the error show that the ld know the needed DSO is `//lib/arm-linux-gnueabihf/libpthread.so.0`? – acgtyrant Dec 21 '15 at 12:27