找不到-lstdc ++的库 - 静态

时间:2014-08-13 01:37:44

标签: c++ macos installation osx-mavericks

我正在尝试构建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中的设置,这不是这里的情况。需要进行的任何更改都需要在文本编辑器中进行。

1 个答案:

答案 0 :(得分:1)

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

ld:找不到-lstdc ++的库 - static表示链接器无法使用静态链接创建对象。请检查是否可以构建静态二进制文件。

像这样创建hello world test:

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

尝试构建它

clang++ test.cpp -o test

clang++ -static test.cpp -o test

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