我正在尝试链接到我的 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
我该如何解决这个错误?
最佳答案
hidden symbol `__dso_handle' in /usr/lib/gcc/i486-linux-gnu/4.4.3/crtbegin.o is referenced by DSO
大概 libprint.so
是引用 DSO。您可以通过以下方式确认:
nm ./libprint.so | grep __dso_handle
如果生成 U __dso_handle
输出,则说明您的 libprint.so
构建不正确(很可能您使用了 ld -shared
来链接它. 不要那样做,使用编译器驱动程序,例如 g++ -shared ...
代替)。
关于linux -/usr/bin/ld : client: hidden symbol `__dso_handle' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17389479/