Skip to content
Advertisement

Symbols not found during linking

I have a problem with a shared library (Linux) and a program that links against this library but does not find the symbols – although they are there. That’s what I have:

A shared library “libetest.so” that is located in /usr/lib. When I do an

 readelf -Ws /usr/lib/libetest.so.0

it gives (beside some others) this output:

54: 000052c0   905 FUNC    LOCAL  DEFAULT   11 ETEST_open_connection

Now I have an application that makes use of ETEST_open_connection(). When I build it with

gcc lib_test.cpp -DENV_LINUX -letest

it fails with a linker error

lib_test.cpp:(.text+0x32): undefined reference to `ETEST_open_connection'

As shown before the symbol is there! Any idea why this fails?

Advertisement

Answer

Please try:

gcc -DENV_LINUX -letest lib_test.cpp

This should be the correct argument order.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement