【问题标题】:/usr/bin/ld: client: hidden symbol `__dso_handle'/usr/bin/ld: 客户端:隐藏符号 `__dso_handle'
【发布时间】:2013-06-27 16:32:31
【问题描述】:

我正在尝试链接我的 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

我该如何解决这个错误?

【问题讨论】:

    标签: linux g++ shared-libraries ld


    【解决方案1】:

    /usr/lib/gcc/i486-linux-gnu/4.4.3/crtbegin.o 中的隐藏符号 `__dso_handle' 被 DSO 引用

    大概libprint.so 是引用DSO。您可以通过以下方式确认:

    nm ./libprint.so | grep __dso_handle
    

    如果产生U __dso_handle 输出,则您的libprint.so 构建不正确(很可能您使用ld -shared 链接它。不要这样做,请使用编译器驱动程序,例如g++ -shared ...)。

    【讨论】:

    • 我的程序遇到了同样的错误。即使我做了“g++ -shared”的事情,错误仍然存​​在。我想知道是不是因为我有“-std=c++0x”,其中无论如何都会包含 __dso_handle 引用?
    猜你喜欢
    • 2021-05-07
    • 1970-01-01
    • 2011-07-16
    • 2012-05-17
    • 2020-04-14
    • 2012-06-20
    • 2012-03-26
    • 2018-12-13
    • 2015-09-22
    相关资源
    最近更新 更多