C++ 使用 Xcode 在 Mac 上构建 Boost
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/893841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Build Boost on Mac with Xcode
提问by Ferruccio
I've recently got acquainted with Boost library and I'd like to use it in my Xcode project. But sadly there is no HowTo or FAQ on how to do it :(
我最近熟悉了 Boost 库,我想在我的 Xcode 项目中使用它。但遗憾的是,没有关于如何做到这一点的 HowTo 或 FAQ :(
What's the sequence of actions to build and use Boost libraries in Xcode?
在 Xcode 中构建和使用 Boost 库的操作顺序是什么?
回答by Ferruccio
The easiest way I've found to do it is to install MacPorts, then you can install/build Boost via a single command:
我发现最简单的方法是安装MacPorts,然后您可以通过单个命令安装/构建 Boost:
sudo port install boost
Plus you get similar access to other open source software. The only downside I've found is that, like any other package management system, they are not always up to date with the latest version.
此外,您还可以访问其他开源软件。我发现的唯一缺点是,与任何其他包管理系统一样,它们并不总是与最新版本保持同步。
If you prefer Homebrewas your package manager, the command is:
如果你更喜欢Homebrew作为你的包管理器,命令是:
brew install boost
回答by jalf
I don't know how to use Boost from XCode (I'm not a Mac programmer), but building boost is usually done through their own build tool, bjam.
我不知道如何从 XCode 使用 Boost(我不是 Mac 程序员),但是构建 Boost 通常是通过他们自己的构建工具 bjam 完成的。
They have a guide to building boost here, and you can download the latest version of bjam here
他们在此处提供了构建 boost 的指南,您可以在此处下载最新版本的 bjam 。
Once it is built, you reference it from Xcode the same way you would any other library. The boost/include should be added to your include path, and the libraries in boost/lib can be referenced for the boost libs that require it.
构建完成后,您可以像引用任何其他库一样从 Xcode 中引用它。boost/include 应该添加到您的包含路径中,并且 boost/lib 中的库可以被需要它的 boost 库引用。
回答by equackenbush
To build boost on a mac, follow the unix variants getting started page (http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html). You won't use Xcode directly to perform the build, but once complete you can add the boost include paths and dylib's to your Xcode project.
要在 Mac 上构建 boost,请遵循 unix 变体入门页面 ( http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html)。您不会直接使用 Xcode 来执行构建,但是一旦完成,您就可以将 boost 包含路径和 dylib 添加到您的 Xcode 项目中。
回答by ch3rryc0ke
I found that to build Boost 1.41.1 on MacOS, you need to do the following:
我发现要在 MacOS 上构建 Boost 1.41.1,您需要执行以下操作:
- Download boost 1.46.1 from here: http://sourceforge.net/projects/boost/files/boost/1.46.1/
- Unpack the file
- Open terminal, cd to the install directory, and do the following:
- 从这里下载 boost 1.46.1:http: //sourceforge.net/projects/boost/files/boost/1.46.1/
- 解压文件
- 打开终端,cd到安装目录,执行以下操作:
chmod u+x configure.sh
cd tools/build/v2/engine/src
chmod u+x build.sh
chmod u+x configure.sh
cd 工具/build/v2/engine/src
chmod u+x build.sh
Then go back to the install directory, and:
然后回到安装目录,然后:
./configure.sh
./configure.sh
If that runs successfully, it will tell you to run:
如果运行成功,它会告诉你运行:
./bjam
./bjam
That's it.. for whatever reason, I needed to set those permissions manually before it would work.
就是这样......无论出于何种原因,我都需要手动设置这些权限才能工作。
回答by Jasper Blues
To build boost on iOS 5.1/6.0 or OSX 10.8 Daniel Sefton has maintained a utility & guide here: http://www.danielsefton.com/2012/03/building-boost-1-49-with-clang-ios-5-1-and-xcode-4-3/
要在 iOS 5.1/6.0 或 OSX 10.8 上构建提升,Daniel Sefton 在此处维护了一个实用程序和指南:http: //www.danielsefton.com/2012/03/building-boost-1-49-with-clang-ios-5 -1-和-xcode-4-3/
This gives you a static (app store friendly) framework that works on simulator or device without having to change any configs.
这为您提供了一个静态(应用商店友好)框架,无需更改任何配置即可在模拟器或设备上运行。
The utility is helpful because it automates the process of setting compiler flags for arm (device) x86 (simulator) platform builds, and then merging them as a universal lib using lipo and finaly packaging as a static framework.
该实用程序很有用,因为它可以自动化为 arm(设备)x86(模拟器)平台构建设置编译器标志的过程,然后使用 lipo 将它们合并为通用库,并最终打包为静态框架。
回答by user2047372
su - root
苏根
enter root password and then run below as root
输入root密码,然后以root身份在下面运行
/opt/local/bin/port install boost
/opt/local/bin/port 安装提升
If you have never logged in as root or forgotten your password, here are the steps to reset root password
如果您从未以 root 身份登录或忘记密码,这里是重置 root 密码的步骤
http://support.apple.com/kb/HT1528?viewlocale=en_US&locale=en_US
http://support.apple.com/kb/HT1528?viewlocale=en_US&locale=en_US
回答by Tomas Andrle
Currently I'm very happy with using Pete Goodliffe's script which builds a framework from the Boost source package for both iOS and Mac. Drag and drop it into a project and it works!
目前我很高兴使用Pete Goodliffe的脚本,该脚本从 iOS 和 Mac 的 Boost 源包构建框架。将它拖放到一个项目中,它就可以工作了!
I keep my copy of the script here:
我把我的脚本副本保存在这里:
https://gist.github.com/catnapgames/8912307
https://gist.github.com/catnapgames/8912307
I don't remember if this is just a copy of the original or if I got some modified version somewhere; all I can say is that it worked for me on iOS & Mac with Xcode 5.0.2 and Boost 1.55
我不记得这是否只是原始版本的副本,还是我在某处获得了一些修改版本;我只能说它在 iOS 和 Mac 上使用 Xcode 5.0.2 和 Boost 1.55 对我有用