在 Windows 中构建 boost 的子集
我正在尝试设置 boost 的一个子集并使用 bjam 正确编译它,但是我没有得到我正在寻找的结果。 我正在使用 boost 1.37.0 在 Windows 上工作。
假设我想要构建/安装库 smart_ptr 和文件系统。 我特意选择了一个仅包含头文件的库和一个需要编译库的库。 我希望将它们构建到类似于我使用 bjam 构建完整的 boost 安装(即不指定任何 --with-libraryX)时得到的目录结构,但当然没有我不感兴趣的所有库 我的
第一个方法是在 bjam 中使用 --with-filesystem --with-smart_ptr ,但是它似乎无法识别 smart_ptr (我尝试了 smartptr 和 smart-ptr 但没有成功)。 我想这是因为它是一个只有标头的库。
当我删除它并且只有 --with-filesystem 时,它似乎将所有库头文件复制到安装路径,并且只构建文件系统的库。 库构建行为是我所希望的,但是我在 boost 目录中安装了大量我不感兴趣的库的头文件。
我的第二种方法是使用bcp复制相关项目。 从某种意义上说,这确实有效,因为我只得到了我关心的项目(及其依赖项)。 但是,他们没有提供任何用于构建复制的库的 make 文件。 这意味着我需要为所有不仅仅是标头的库设置项目文件并手动构建它们。
所以我的问题基本上是,有没有一种方法可以选择性地构建 boost,只复制我感兴趣的库的标头,并且只为我感兴趣的非标头库构建库文件(以及它们是的 boost 库)取决于课程)?
可能有大量基于手动/脚本的解决方案,但如果我可以只使用 bjam 运行某些东西,对我来说会更有用,因为添加新库或升级到新的 boost 版本将非常简单。
编辑: 添加了第一种方法的完整命令行:
bjam install --prefix=c:\temp\boostsmall
--build-dir=C:\temp\boostsmalltemp --layout=system
--with-filesystem variant=debug link=static threading=multi
runtime-link=static
将scoped_ptr更改为smart_ptr
I'm trying setup a subset of boost and get it properly compiled using bjam, however I'm not getting the result I'm looking for. I'm working on windows using boost 1.37.0.
Let's say I want the libraries smart_ptr and filesystem built/installed. I intentionally chose a header only library and one library needing to compile a library. I want them to be built into a directory structure similar to the one I would get if I built a complete boost installation with bjam (i.e not specifying any --with-libraryX) but of course without all the libraries I'm not interested in.
My first approach was to use the --with-filesystem --with-smart_ptr in bjam, however it seemed like it didn't recognize smart_ptr (I tried smartptr and smart-ptr without success). I guess this is because it's a header only library.
When I removed it and only had --with-filesystem it seemed to copy ALL libraries header files to the install path and only build the libraries for filesystem. The library building behavior was the one I hoped for, but I got tons of header files for libraries I'm not interested in installed in my boost directory.
My second approach was to use bcp to copy the relevant projects. This did work out in the sense that I only got the projects I cared about (and their dependencies). However they didn't provide any make files for building the libraries that was copied. This means I would need to setup projects files for all the libraries that are not header only and manually build them.
So my question is basically, is there a way of selectively building boost that only copies the headers for the libraries I'm interested in and only building library files for the non header only libraries I'm interested in (and the boost libraries they are dependent on course)?
There are probably tons of manual/scripting based solutions for this, but if I could get something running only using bjam would be way more useful for me since adding new libraries or upgrading to a new boost version would be very simple.
EDIT:
Added the complete command line for the first approach:
bjam install --prefix=c:\temp\boostsmall
--build-dir=C:\temp\boostsmalltemp --layout=system
--with-filesystem variant=debug link=static threading=multi
runtime-link=static
Changed scoped_ptr to smart_ptr
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好问题! 我想这是我最近设法弄清楚的一个问题。
我已经安装了完整的 Boost 库,包括需要单独编译的库。
我设法使用以下步骤为我正在开发的特定应用程序创建 Boost 库 (regex) 的子集:
首先确保首先安装 bcp 可执行文件。 在 Boost 根文件夹中,导航到 tools/bcp 文件夹并运行此处的 bjam.exe。 对我来说,这在 [Boost path]\bin.v2\tools\bcp\msvc-10.0\release\link-static 目录中创建了 bcp 可执行文件:
然后创建您希望 Boost 子集驻留的文件夹。 这可能已经是您正在处理的 Visual Studio 项目的文件夹。
运行您创建的 bcp 可执行文件,确保包含您希望包含的库,以及 boost 根目录和目标文件夹的位置。 观察所需的 Boost 组件(例如正则表达式)是如何包含在目标文件夹中的。
bcp.exe regex --boost="C:\Program Files\boost_1_55_0\boost_1_55_0" C:\Projects\RegexProject\BoostLite
在 Visual Studio 项目中,将附加包含目录和库设置为指向“Boost lite”已创建的文件夹。
我发现这对我有用。 来自其他人的经验的任何反馈将不胜感激。
可以找到描述相同内容的博客文章这里。
Great question! This is an issue I have recently managed to figure out, I think.
I already had the full Boost libraries installed, including the ones requiring separate compilation.
I managed to create a subset of the Boost libraries (regex) for a particular application I was working on using the following steps:
First ensure the bcp executable is installed in the first place. In your Boost root folder, navigate to the tools/bcp folder and run the bjam.exe in here. For me this created the bcp executable in [Boost path]\bin.v2\tools\bcp\msvc-10.0\release\link-static directory:
Then create the folder where you would like the Boost subset to reside. This might already be a folder for a Visual Studio project you are working on.
Run the bcp exectubale you created, making sure to include the libraries you wish to include, as well as the location of the boost root directory and the destination folder. Observe how the required Boost components (eg for regex) have been included in your destination folder.
bcp.exe regex --boost="C:\Program Files\boost_1_55_0\boost_1_55_0" C:\Projects\RegexProject\BoostLite
In your Visual Studio project set the Additional Include Directories and Libraries to point to the 'Boost lite' folder that was created.
One final thing - which I think is described previously - I needed to go to my regular Boost folder setup and copy the required stage/lib folder containing all the lib files needed for the subset version and copy them here, just a few regex-related lib files in my case.
I found that this worked for me. Any feedback from other persons experiences would be appreciated.
A blog posting describing the same thing can be found here.
解决了。
bcp 解决方案具有项目的 make 文件,但是我需要将工具目录和 boost 目录的根目录复制到复制所有库的位置才能运行。
Solved it.
The bcp solution had make files for the projects, however I needed to copy the tools directory and the root of the boost directory to the place I copied all my libs to get things up running.