在c ++中使用dlopen时出现未定义的引用错误

时间:2015-08-20 10:31:45

标签: c++ cmake cross-compiling dlopen qpid

我正在尝试从debian中为一个arm系统交叉编译 apache-qpid

undefined reference to __dlopen错误,但似乎与之前的警告有关:

在静态链接的应用程序中使用'dlopen'需要在运行时使用glibc版本中用于链接的共享库...

以下是详细信息:

[ 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'

我不知道究竟发生了什么以及如何解决它。

Here有一个类似的事情,我尝试添加-static -ldl -lc C_FLAGS,但没有任何区别。

任何帮助表示感谢。

编辑:

编辑:

我不确定究竟是什么解决了这个问题,但我认为-ldl看起来完全是libdl.so,但是在arm目录中,它是libdl-2.19.so,因此可能它正在寻找for and find in another directory。我已将libdl.solibdl-2.19.so相关联,现在正在编译。

2 个答案:

答案 0 :(得分:1)

链接器需要选项,而不是编译器。见LDFLAGS。

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

  

当应该调用编译器时,为编译器提供额外的标志   链接器,'ld',例如-L。应该将库(-lfoo)添加到   相反,LDLIBS变量。

答案 1 :(得分:0)

如果在制作步骤中发生此错误,请尝试执行

make LIBS=-ldl

确保LDFLAGS中存在库路径

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