C++ 如何使用 MinGW 构建 Boost 1.55?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20265879/
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
How do I build Boost 1.55 with MinGW?
提问by Warezovvv
I have downloaded Boost 1.55 and MinGW.
我已经下载了 Boost 1.55 和 MinGW。
The console answers me that I haven't any command. I can't understand how to bind two paths and activate the GCC compiler.
控制台回答我说我没有任何命令。我无法理解如何绑定两个路径并激活 GCC 编译器。
P.S.: If I build boost with Microsoft's compiler I will have about 8 mistakes with error 3861!!
PS:如果我使用 Microsoft 的编译器构建 boost,我将有大约 8 个错误,错误 3861!
How can I build it?
我该如何构建它?
回答by greatwolf
First make sure your mingw's bin directory is in your environment PATH
so gcc
and g++
is callable from your command prompt. Afterwards go into your boost's root directory of where you extracted the files.
首先确保您的 mingw 的 bin 目录在您的环境中PATH
,gcc
并且g++
可以从您的命令提示符调用。然后进入你解压文件的boost根目录。
Follow that with a bootstrap + b2.exe to build. For example, let's say you only want to compile the regex portion of boost. The follow commands should do the trick:
使用引导程序 + b2.exe 进行构建。例如,假设您只想编译 boost 的正则表达式部分。以下命令应该可以解决问题:
bootstrap gcc
b2 toolset=gcc regex
You can use:
您可以使用:
b2 --show-libraries
to get a listing of modules you can build individually. Of course you can build all of them with just:
获取可以单独构建的模块列表。当然,您可以使用以下命令构建所有这些:
b2 toolset=gcc
Check out Boost Invocationfor a detailed list of available options.
查看Boost Invocation以获取可用选项的详细列表。
回答by Antimony
Greatwolf's answer didn't work for me, so here's how I managed to get it working.
Greatwolf 的回答对我不起作用,所以这是我设法让它工作的方法。
First, make sure MinGW\bin
is on your path
首先,确保MinGW\bin
在你的路上
Go to the tools\build\v2
directory of your boost folder. For example, in my case it was C:\Boost\boost_1_55_0\tools\build\v2
. Then run
转到tools\build\v2
boost 文件夹的目录。例如,就我而言,它是C:\Boost\boost_1_55_0\tools\build\v2
. 然后运行
bootstrap mingw
After that, switch to the root Boost directory (this part is important since b2 detects what to build based on current directory)
之后,切换到 Boost 根目录(这部分很重要,因为 b2 根据当前目录检测要构建的内容)
Now, if you want to build Filesystem, do
现在,如果您想构建文件系统,请执行
tools\build\v2\b2 toolset=gcc --build-type=complete stage --with-filesystem
This will put libboost_filesystem-mgw48-d-1_55.dll
etc. in stage\lib
. If you want to build everything, just leave off the --with-filesystem
part.
这会将libboost_filesystem-mgw48-d-1_55.dll
等放入stage\lib
. 如果您想构建所有内容,请忽略该--with-filesystem
部分。
回答by Miguel Mu?oz
I was able to build it following the instructions from Antimony. However I initially got this error:
我能够按照 Antimony 的说明构建它。但是,我最初收到此错误:
Bootstrapping the build engine
\Windows was unexpected at this time.
The error was solved by clearing the PATH variable and putting just the MinGW folder in it:
通过清除 PATH 变量并将 MinGW 文件夹放入其中解决了该错误:
set PATH=C:\MinGW\bin
Then Antimony's instructions did the job for me. Thanks!!
然后锑的指示为我完成了这项工作。谢谢!!
Just two other small things that might be helpful. BOOST for MinGW should be build from the Windows shell, not from the MSYS shell. And in version 1.57 the bootstrap.bat script is no longer in tools\build\v2, but directly in tools\build.
还有另外两件小事可能会有所帮助。BOOST for MinGW 应该从 Windows shell 构建,而不是从 MSYS shell 构建。在 1.57 版本中,bootstrap.bat 脚本不再在 tools\build\v2 中,而是直接在 tools\build 中。
回答by david.libremone
If you have installed MinGW/GCC as part of TDM-GCC, you will have a "MinGW Command Prompt" that you can launch. This loads a command prompt window and puts the GCC compiler on the PATH for that window. (Similar to the "Developer Command Prompt" that is installed with Visual Studio.)
如果您已将 MinGW/GCC 作为TDM-GCC 的一部分安装,您将拥有一个可以启动的“MinGW 命令提示符”。这将加载一个命令提示符窗口并将 GCC 编译器放在该窗口的 PATH 上。(类似于随 Visual Studio 安装的“开发人员命令提示符”。)
I think that the "MinGW distro"comes with one too.
我认为“MinGW 发行版”也带有一个。
If you have an integrated command prompt you can simply:
如果您有一个集成的命令提示符,您可以简单地:
- Launch "MinGW Command Prompt"
- Go to your Boost folder (e.g. C:/Boost)
- Run
bootstrap gcc
- Run
b2 toolset=gcc
(or whateverb2
command you need)
- 启动“MinGW 命令提示符”
- 转到您的 Boost 文件夹(例如 C:/Boost)
- 跑
bootstrap gcc
- 运行
b2 toolset=gcc
(或b2
您需要的任何命令)
If you are working from examples where someone is not explicitly setting the toolset, you will have to add toolset=gcc
yourself. Note that toolset
must be placed in the propertyposition not the optionor commandposition. From b2 --help
:
如果您正在使用某人未明确设置工具集的示例,则必须添加toolset=gcc
自己。注意toolset
必须放在属性位置而不是选项或命令位置。来自b2 --help
:
b2 [options] [properties] [install|stage]
So if someone was writing the command to invoke the install
command with the --prefix
option, they'd write it as:
因此,如果有人编写命令以install
使用--prefix
选项调用命令,他们会将其写为:
b2 --prefix=C:\boost-build install
And you'd re-write it as:
你可以把它改写为:
b2 --prefix=C:\boost-build toolset=gcc install
See b2 --help
for more details.
有关b2 --help
更多详细信息,请参阅。