/usr/bin/ld: client: 隐藏符号 `__dso_handle'

5

我正在尝试在我的C++程序中链接一个共享库。

我使用的命令是:g++ -o client Client.cpp -L. -lprint

下面是错误信息:

/usr/bin/ld: client: hidden symbol `__dso_handle' in /usr/lib/gcc/i486-linux-gnu/4.4.3/crtbegin.o is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

我该如何解决这个错误?
1个回答

6

/usr/bin/objdump -p libprint.so | grep NEEDED

It should output the name of the DSO that libprint.so is referencing.

nm ./libprint.so | grep __dso_handle

如果输出显示出 U __dso_handle,这意味着你的 libprint.so 构建不正确(很可能你使用了 ld -shared 进行链接。不要这样做,应该使用编译器驱动程序,例如 g++ -shared ...)。

我在我的程序中遇到了相同的错误。即使我执行了"g++ -shared"操作,该错误仍然存在。我想知道是否是因为我有"-std=c++0x",这将无论如何包含__dso_handle引用? - user1783732

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接