【问题标题】:library not found for -lstdc++-static找不到 -lstdc++-static 的库
【发布时间】:2014-08-13 01:37:43
【问题描述】:

我正在尝试构建 wxFormBuilder_v3.5.0-beta-source。它带有一个用于创建构建文件的 shell 文件,但它总是遇到以下错误:

==== Building Premake4 ====
Linking Premake4
ld: library not found for -lstdc++-static
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [bin/release/premake4] Error 1
make: *** [Premake4] Error 2
./create_build_files4.sh: line 91: ./premake/macosx/bin/release/premake4: No such file or directory
./create_build_files4.sh: line 92: ./premake/macosx/bin/release/premake4: No such file or directory
./create_build_files4.sh: line 93: ./premake/macosx/bin/release/premake4: No such file or directory
./create_build_files4.sh: line 95: ./premake/macosx/bin/release/premake4: No such file or directory

我正在运行 Mac OS X 10.9.4,是的,我已经安装了 XCode,并且之前已经在这台机器上成功构建/安装了 C++ 项目。

我知道我必须先安装 wxWidgets 才能使其工作,并且我已经成功构建/编译/安装了 wxWidgets。

这是 shell 文件的第 87-96 行(我在行号前加上了前缀供您参考):

[87] # Build premake
[88] cd build
[89] make CONFIG=Release -C./premake/$platform
[90]
[91] ./premake/$platform/bin/release/premake4 --file=./premake/solution.lua $wxunicode $wxroot $wxversion $mediactrl $shared $arch codeblocks
[92] ./premake/$platform/bin/release/premake4 --file=./premake/solution.lua $wxunicode $wxroot $wxversion $mediactrl $shared $arch $rpath codelite
[93] ./premake/$platform/bin/release/premake4 --file=./premake/solution.lua $wxunicode $wxroot $wxversion $mediactrl $shared $arch $rpath gmake
[94] if [ "$platform" = "macosx" ]; then
[95]    ./premake/$platform/bin/release/premake4 --file=./premake/solution.lua $wxunicode $wxroot $wxversion $mediactrl $shared $arch xcode3
[96] fi

我并不担心文件路径丢失。我尝试直接从正确的目录运行make,但仍然出现此错误:

==== Building Premake4 ====
Linking Premake4
ld: library not found for -lstdc++-static
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [bin/release/premake4] Error 1
make: *** [Premake4] Error 2

我主要关心的是找到-lstdc++-static 库并安装它,但我无法在网上找到它。我能找到的唯一与之相关的是在编译 iOS 应用程序时更改 XCode 中的设置,这里不是这种情况。任何需要进行的更改都需要在文本编辑器中进行。

【问题讨论】:

    标签: c++ macos installation osx-mavericks


    【解决方案1】:

    这意味着premake文件路径:./premake/macosx/bin/release/premake4不存在。请注意,您使用的是相对路径(从 ./ 开始),而不是绝对路径。尝试使用绝对路径并检查 premake4 可执行文件的位置。

    ld: library not found for -lstdc++-static 意味着您的链接器无法使用静态链接创建对象。请检查您是否可以构建静态二进制文件。

    像这样创建 hello world 测试:

    #include <iostream>
    int main()
    {
      std::cout << "Hello world!" << std::endl;
      return 0;
    }
    

    尝试构建它

    clang++ test.cpp -o test
    

    clang++ -static test.cpp -o test
    

    此类测试的结果可确保您能够或根本无法创建二进制文件。

    【讨论】:

    • 文件的路径不正确,但即使更正路径似乎也无法修复它,因为它正在寻找的文件无处可寻。如果我转到实际文件夹并直接运行make,我仍然会得到ld: library not found for -lstdc++-static,而不会出现没有此类文件/目录错误。
    • 这是另一个错误,与链接器有关。您是否尝试过使用静态链接的“hello world”方法?
    • 你能查一下,你到底叫什么:clang 或 clang++?如果您调用 clang - 尝试将其替换为 clang++
    猜你喜欢
    • 2019-02-25
    • 2018-12-06
    • 2012-12-05
    • 1970-01-01
    • 2015-01-30
    • 1970-01-01
    • 2019-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多