在 Windows 上构建 Boost
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7947542/
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
Building Boost on Windows
提问by Martynas
I am trying to build boost libraries on Windows 7 x64 machine using mingw. When I try to run b2
我正在尝试使用 mingw 在 Windows 7 x64 机器上构建 boost 库。当我尝试运行 b2
b2 --build-dir="C:\boost\build" --toolset=gcc --with-python
to build the libraries I get an error
构建库时出现错误
Jamroot:138: in modules.load
rule boostcpp.set-version unknown in module Jamfile</C:/Users/root/Downloads/boost_1_47_0>.
C:/Users/root/Downloads/boost_1_47_0/tools/build/v2/build\project.jam:314: in load-jamfile
C:/Users/root/Downloads/boost_1_47_0/tools/build/v2/build\project.jam:62: in load
C:/Users/root/Downloads/boost_1_47_0/tools/build/v2/build\project.jam:168: in project.find
C:/Users/root/Downloads/boost_1_47_0/tools/build/v2\build-system.jam:570: in load
C:\Users\root\Downloads\boost_1_47_0\tools\build\v2/kernel\modules.jam:283: in import
C:\Users\root\Downloads\boost_1_47_0\tools\build\v2\kernel\bootstrap.jam:142: in boost-build
C:\Users\root\Downloads\boost_1_47_0\boost-build.jam:17: in module scope
What am I doing wrong and how to fix it? Any help is appreciated
我做错了什么以及如何解决?任何帮助表示赞赏
Thanks
谢谢
Edit:
编辑:
I want to use boost libraries with qt sdk, which uses mingw. That's why I can't use the boost installer. Of course, unless I fail to find solution to this problem, I will have to resort to using qt built with msvc.
我想使用带有 mingw 的 qt sdk 的 boost 库。这就是我不能使用 boost 安装程序的原因。当然,除非我找不到解决这个问题的方法,否则我将不得不求助于使用 msvc 构建的 qt。
回答by Franck Dernoncourt
Here is a tutorialI had written to compile Boost 1.45.0 on Windows 7 using MinGW. I copy the tutorial here in case the link breaks:
这是我编写的使用 MinGW 在 Windows 7 上编译 Boost 1.45.0的教程。我在这里复制教程以防链接断开:
1) First we need to compile Boost. We'll use Boost's latest version: 1.45.0 (probably not the latest version at the time you'll read this tutorial.
1)首先我们需要编译Boost。我们将使用 Boost 的最新版本:1.45.0(可能不是您阅读本教程时的最新版本。
1.1) Download Boost sources:
1.1) 下载 Boost 源:
- http://www.boost.org/users/download/
- or directly: http://sourceforge.net/projects/boost/files/boost/1.45.0/boost_1_45_0.7z/download)
- http://www.boost.org/users/download/
- 或直接:http: //sourceforge.net/projects/boost/files/boost/1.45.0/boost_1_45_0.7z/download)
1.2) To compile Boost, we need to use BJam. BJam's sources are included in boost's sources. Yet, we can't use BJam's binaries: we must compile it because of the following problem: http://comments.gmane.org/gmane.comp.lib.boost.user/64146.
1.2) 要编译 Boost,我们需要使用 BJam。BJam 的来源包含在 boost 的来源中。然而,我们不能使用 BJam 的二进制文件:我们必须编译它,因为以下问题:http://comments.gmane.org/gmane.comp.lib.boost.user/64146 。
To compile BJam, go to Boost's sources, find build.bat (should be located in \boost_1_45_0\tools\build\v2\engine\src), run cmd, cd to build.bat's folder and execute: build.bat gcc
(source)
要编译的bjam,去Boost的来源,找到的build.bat(应位于\ boost_1_45_0 \工具\编译\ V2 \发动机\ SRC),运行CMD,cd到的build.bat的文件夹,然后执行:build.bat gcc
(源)
Compilation lasts less than 30 seconds.
编译持续时间少于 30 秒。
- Note 1: gcc must be in the $PATH. If you don't have gcc, you can get it at http://www.mingw.org/wiki/InstallationHOWTOforMinGW. Use the automated installer if you don't want to waste time on it. (don't forget to select the C++ compiler during the installation, it will only install the C compiler by default)
- Note 2: don't call cygwin's gcc otherwise you'll get an "Access denied" error, see http://omgili.com/mailinglist/cygwin/cygwin/com/m2t961f6df41004191807y75bc02cfiabd7f684a8d5f8camailgmailcom.htmlfor more details. Better use gcc included in the MinGW you will later use with your IDE.
- 注 1:gcc 必须在 $PATH 中。如果你没有 gcc,你可以在http://www.mingw.org/wiki/InstallationHOWTOforMinGW得到它。如果您不想浪费时间,请使用自动安装程序。(安装时不要忘记选择C++编译器,默认只会安装C编译器)
- 注意 2:不要调用 cygwin 的 gcc 否则你会得到一个“访问被拒绝”错误,请参阅http://omgili.com/mailinglist/cygwin/cygwin/com/m2t961f6df41004191807y75bc02cfiabd7f684a8d5f8camailg了解更多详情 更好地使用 MinGW 中包含的 gcc,您稍后将与您的 IDE 一起使用。
1.3) Once BJam is compiled, we can now compile Boost. Add bjam.exe in $PATH, run cmd, cd \boost_1_45_0 then execute:
1.3) 一旦 BJam 被编译,我们现在可以编译 Boost。在 $PATH 中添加 bjam.exe,运行 cmd,cd \boost_1_45_0 然后执行:
bjam --toolset=gcc "--prefix=C:\DestinationFolder" install
where DestinationFolder
is whatever folder path you want (source).
DestinationFolder
您想要的任何文件夹路径在哪里(source)。
Compilation lasts around 30 minutes.
编译持续约 30 分钟。
回答by David Belle
This thread is a year old, but I had the same problem and got it working, so in case anyone else needs a solution, here's mine.
该线程已有一年历史,但我遇到了同样的问题并使其正常工作,因此如果其他人需要解决方案,这是我的。
bjam was looking for a file called "boostcpp.jam" which didn't exist in the production version of boost. Luckily, you can find it on github.
bjam 正在寻找一个名为“boostcpp.jam”的文件,该文件在 boost 的生产版本中不存在。幸运的是,你可以在 github 上找到它。
https://github.com/iNiKe/boost/blob/master/boostcpp.jam
https://github.com/iNiKe/boost/blob/master/boostcpp.jam
Download that file (or copy-paste it from your browser to a new file) and save it as "boostcpp.jam" in your boost directory (or maybe it's the location where you run bjam from...they happened to be the same directory in my situation) and run the command again. Hopefully it'll work for you too.
下载该文件(或将其从浏览器复制粘贴到一个新文件中)并将其另存为 boost 目录中的“boostcpp.jam”(或者它可能是您运行 bjam 的位置...它们碰巧是相同的在我的情况下的目录)并再次运行命令。希望它也对你有用。
回答by Shadow2531
For those that only need 32bit, STL's Mingw Distrohas Boost included with all the libs already built for it.
对于那些只需要 32 位的人来说,STL 的 Mingw Distro将 Boost 包含在已经为其构建的所有库中。