clang: error: link命令失败,退出代码为1(使用-v查看调用)

ld: library not found for -lboost_system clang: error: linker command failed with exit code 1 (use -v to see invocation)

本文关键字:使用 调用 代码 命令 link error 失败 clang 退出      更新时间:2023-10-16

在尝试了几种解决方案后,我认为我需要一些帮助来理解如何为Mac OSX Lion正确构建Boost,在XCode 4上构建跨平台应用程序没有成功=s

我遵循了这个指南。并依次执行以下命令:

cd /Users/me/Documents/boost_1_53_0
./bootstrap.sh --prefix=installation
cd /Users/me/Documents/boost_1_53_0/tools/build/v2
./bootstrap.sh
./b2 install --prefix=installation
export PATH=$PATH:installation/bin
cd /Users/me/Documents/boost_1_53_0
./b2 --build-dir=installation toolset=darwin cxxflags="-arch i386" address-model=32 architecture=x86 stage

在尝试在XCode上编译应用程序后,我得到了问题标题中的错误,并进行了以下编辑:

将这些库添加到"Build Phases"下的"Link Binary With Libraries"中:

libboost_filesystem.dylib
libboost_system.dylib

并添加了"$(srroot)/.."/boost_1_53_0"到标头和库搜索路径。

看看Stackoverflow上的其他一些问题,很多人似乎用makefiles来构建boost,并在makefile中传递LDFLAGS=-L/opt/local/lib;

我在哪里可以找到一个很好的教程或例子,建设促进?我没有自己制作makefile的经验,尽管我在这里和那里进行了一些简单的编辑。

检查您的boost dylib在哪里。可能是在"$(SRCROOT)/../boost_1_53_0"中的某个中间目录下?例如:$(SRCROOT)/../boost_1_53_0/lib。如果是这样,将整个路径添加到构建设置中的"库搜索路径"中。
顺便说一下:您确定要动态链接而不是静态链接吗?