undefined reference to `Tins::DNS::queries() const'

94 views
Skip to first unread message

C.

unread,
Aug 25, 2017, 9:21:18 PM8/25/17
to libtins
Hey everyone,

I have a small project currently using dot11decrypt (https://github.com/mfontanini/dot11decrypt) that I would lighten a bit (my Raspberry Pi is executing it).
I am mainly interested by the packet decryption and the DNS sniffing. Hence I found and try the basic example (https://libtins.github.io/examples/dns-queries/). Unfortunately, I have some ugly compilation/linking error.

$ g++ -ltins -std=c++11 test.cpp
/tmp/ccCD0vyX.o: In function `callback(Tins::PDU const&)':
test.cpp:(.text+0x5a): undefined reference to `Tins::DNS::queries() const'
collect2: error: ld returned 1 exit status

If anyone can help me with that, or notice the same behaviour, I'd really appreciate.

Good night all,
C.

Matias Fontanini

unread,
Aug 25, 2017, 9:43:08 PM8/25/17
to libtins
The issue is likely in the order of parameters you're using when invoking g++. Always put your link directives at the end:

g++ -std=c++11 test.cpp -ltins


C.

unread,
Aug 26, 2017, 3:54:39 AM8/26/17
to libtins
Unfortunately, this does not change the error I get.

$ g++ -std=c++11 test.cpp -ltins
/tmp/ccqi4oYt.o: In function `callback(Tins::PDU const&)':
test.cpp:(.text+0x5a): undefined reference to `Tins::DNS::queries() const'
collect2: error: ld returned 1 exit status

Are you able to compile the above example?
I'm on Arch Linux, litins is compiled from git.

C.

unread,
Aug 26, 2017, 4:17:59 AM8/26/17
to libtins
As one could expect, other examples have the same behaviour. Below, my terminal output for this example: https://libtins.github.io/examples/code/dns-spoof.cpp

$ g++ -std=c++11 dns-spoof.cpp -ltins -lpthread
/tmp/cc3nc6pu.o: In function `callback(Tins::PDU const&)':
dns-spoof.cpp:(.text+0xf7): undefined reference to `Tins::DNS::queries() const'
dns-spoof.cpp:(.text+0x412): undefined reference to `Tins::EthernetII::EthernetII(Tins::HWAddress<6ul> const&, Tins::HWAddress<6ul> const&)'
/tmp/cc3nc6pu.o: In function `Tins::PDU::PDU(Tins::PDU&&)':
dns-spoof.cpp:(.text._ZN4Tins3PDUC2EOS0_[_ZN4Tins3PDUC5EOS0_]+0x71): undefined reference to `Tins::PDU::parent_pdu(Tins::PDU*)'
collect2: error: ld returned 1 exit status



C.

unread,
Aug 26, 2017, 4:42:05 AM8/26/17
to libtins
Problem solved.

$ g++ -std=c++11 dns-spoof.cpp -Wl,-rpath,/usr/local/lib /usr/local/lib/libtins.so

I found it out by fist linking successfully with CMake, and then by checking the linking options.

Know, regarding why I need to specify the library path instead of simply adding the -ltins option, I really don't know.
When I run g++ with -ltins option I get LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/../../../:/lib/:/usr/lib/

Anyway, thanks for helping.
Reply all
Reply to author
Forward
0 new messages