dlopen中对__dlopen的未知引用 [英] Unknown reference to __dlopen in dlopen

查看:172
本文介绍了dlopen中对__dlopen的未知引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dlopen 位于 libdl.a ,但是当我链接我的应用程序 libdl .a ,gcc链接器抛出此错误: unknow对dlopen中调用的__dlopen的引用

dlopen is located in libdl.a but when I link my application against libdl.a , gcc linker throw this error : unknow reference to __dlopen called in dlopen

我应该导入另一个 .a

推荐答案

编译静态a dlopen mockup程序, gcc (Archlinux / gcc版本4.6.1 20110819(prerelease))告诉我:

When I try to compile statically a dlopen mockup program, gcc (Archlinux/gcc version 4.6.1 20110819 (prerelease)) tells me:

$ gcc test.c  -ldl -static  
/tmp/ccsWe4RN.o: In function `main': test.c:(.text+0x13): 
warning: Using 'dlopen' in statically linked applications requires 
at runtime the shared libraries from the glibc version used for linking

p>

and indeed, when I ran this script in /usr/lib/

for i in *.a; 
do 
    echo $i; 
    readelf -a $i | grep __dlopen;
done

我看到:

libc.a
16: 0000000000000080    69 FUNC    GLOBAL DEFAULT    1 __dlopen
000000000000  002300000001 R_X86_64_64       0000000000000000 __dlopen + 0
35: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __dlopen

,如第一行 libc.a 确实定义了你缺少的符号。

so as per the first line, libc.a does define your missing symbole.

在我的系统中, gcc test.c -ldl -static 足以使应用程序运行,但

In my system, gcc test.c -ldl -static is enough to make the application run, but

gcc <file> -static -ldl -lc

应该可以解决您系统中的问题。

should fix the problem in your system.

这篇关于dlopen中对__dlopen的未知引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆