【问题标题】:static link boost with g++ on MacOS在 MacOS 上使用 g++ 进行静态链接提升
【发布时间】:2014-03-21 13:41:28
【问题描述】:

我正在使用 FLTK 工具包在 C++ 中构建一个项目,并包含用于序列化的 boost 库,并且希望静态链接到它们,因为我不能保证 boost 库在其他机器上的存在。

我从 boost 下载中重新运行了安装命令,如下所示:

sudo ./b2 link=static
sudo ./b2 install link=static

然后我就这样编译我的项目

g++ `fltk-config --use-forms --use-gl --use-images --ldflags --cxxflags` xxxx.cpp  -L/opt/local/lib/ -Wl, -Bstatic -lboost_iostreams -lboost_serialization -Wl, -Bdynamic -o program_name

但是失败了,这只是一个输出

ld: file not found: 
collect2: ld returned 1 exit status

我不太确定在这里做什么,有人有什么指导吗?

【问题讨论】:

  • 将 -v(或 --v)添加到命令行以获取更多信息。您的引导库在 /opt/local/lib 中吗?不确定,为什么命令行参数是重音?

标签: c++ boost static g++ static-linking


【解决方案1】:

您在-Wl, -Bstatic 中有一个空格。删除该空间,例如-Wl,-Bstatic

同样适用于-Wl, -Bdynamic

【讨论】:

  • 好点,但仍然无法正常工作。也遵循了这里的建议 stackoverflow.com/questions/12022543/… 并通过 macports 安装了我能想到的所有东西,现在正在使用这个命令编译 "g++-mp-4.7 fltk-config --use-forms --use-gl --use-images --ldflags --cxxflags xxxx.cpp fltk-config --ldflags -L/opt/local/lib/ -Wl,-Bstatic -lboost_iostreams -lboost_serialization -Wl,-Bdynamic -o program_name" 但它仍然返回以下错误:ld: unknown option: -Bstatic collect2: error: ld returned 1 exit status
猜你喜欢
  • 2012-12-17
  • 1970-01-01
  • 1970-01-01
  • 2015-01-28
  • 2011-01-20
  • 1970-01-01
  • 1970-01-01
  • 2010-09-26
  • 2012-06-29
相关资源
最近更新 更多