Mert Mertce
Mert Mertce

Reputation: 1223

undefined reference error in using dlopen in c++

I am trying to cross-compile apache-qpid for an arm system from a debian.

There is undefined reference to __dlopen error, but it seems that it is related to the previous warning:

using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking ...

Here is the detail:

[ 86%] Linking CXX shared library libqpidcommon.so
CMakeFiles/qpidcommon.dir/qpid/sys/posix/Shlib.cpp.o: In function       
`qpid::sys::Shlib::load(char const*)':
/home/mert/qpid-cpp-0.34/src/qpid/sys/posix/Shlib.cpp:32: warning: Using   
'dlopen' in statically linked applications requires at runtime the shared  
libraries from the glibc version used for linking
/home/mert/IDE/cVEND/00.00.14/bin/../arm-feig-linux-  
gnueabi/sysroot/usr/lib/libdl.a(dlopen.o): In function `dlopen':
dlopen.c:(.text+0xc): undefined reference to `__dlopen'

I do not know what is happening exactly and how to solve it.

Here there is a similiar thing, I tried to add -static -ldl -lc C_FLAGS but made no difference.

Any help appreciated.

EDIT :

EDIT :

I am not sure exactly what is solved the problem, but I think that -ldl was looking exactly for libdl.so, but in arm directory, it was libdl-2.19.so, thus, probably it was then looking for and finding in another directory. I have linked libdl.so to libdl-2.19.so and now it is compiling.

Upvotes: 1

Views: 2962

Answers (2)

ashwanth selvam
ashwanth selvam

Reputation: 506

If this error occurs during the make step try doing

make LIBS=-ldl

And make sure the library path is present in LDFLAGS

export LDFLAGS=-L<path/to/ldl>

Upvotes: 0

HelloWorld
HelloWorld

Reputation: 1863

The linker needs the options, not the compiler. See LDFLAGS.

https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable instead.

Upvotes: 1

Related Questions