简体   繁体   English

如何使用MinGW构建Boost 1.55?

[英]How do I build Boost 1.55 with MinGW?

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编译器。

PS: If I build boost with Microsoft's compiler I will have about 8 mistakes with error 3861!! PS:如果我使用微软的编译器构建增强功能,我将有大约8个错误,错误3861!

How can I build it? 我怎样才能建造它?

First make sure your mingw's bin directory is in your environment PATH so gcc and g++ is callable from your command prompt. 首先确保你的mingw的bin目录在你的环境PATH所以gccg++可以从命令提示符调用。 Afterwards go into your boost's root directory of where you extracted the files. 然后进入您提取文件的位置的根目录。

Follow that with a bootstrap + b2.exe to build. 然后使用bootstrap + b2.exe进行构建。 For example, let's say you only want to compile the regex portion of boost. 例如,假设您只想编译boost的正则表达式部分。 The follow commands should do the trick: 以下命令应该可以解决问题:

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 Invocation for a detailed list of available options. 查看Boost Invocation以获取可用选项的详细列表。

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. 转到boost文件夹的tools\\build\\v2目录。 For example, in my case it was C:\\Boost\\boost_1_55_0\\tools\\build\\v2 . 例如,在我的情况下,它是C:\\Boost\\boost_1_55_0\\tools\\build\\v2 Then run 然后跑

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 现在,如果你想构建Filesystem,那就做吧

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 . 这将把libboost_filesystem-mgw48-d-1_55.dll等放在stage\\lib If you want to build everything, just leave off the --with-filesystem part. 如果你想构建所有东西,只需--with-filesystem部分。

I was able to build it following the instructions from Antimony. 我能按照锑的指示建造它。 However I initially got this error: 但是我最初得到了这个错误:

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. 应该从Windows shell构建Boost for MinGW,而不是从MSYS shell构建。 And in version 1.57 the bootstrap.bat script is no longer in tools\\build\\v2, but directly in tools\\build. 在版本1.57中,bootstrap.bat脚本不再位于tools \\ build \\ v2中,而是直接位于tools \\ build中。

If you have installed MinGW/GCC as part of TDM-GCC , you will have a "MinGW Command Prompt" that you can launch. 如果您已将MinGW / GCC安装为TDM-GCC的一部分,则可以启动“MinGW命令提示符”。 This loads a command prompt window and puts the GCC compiler on the PATH for that window. 这将加载命令提示符窗口并将GCC编译器放在该窗口的PATH上。 (Similar to the "Developer Command Prompt" that is installed with Visual Studio.) (类似于随Visual Studio一起安装的“Developer Command Prompt”。)

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" 启动“MinGW Command Prompt”
  • Go to your Boost folder (eg C:/Boost) 转到Boost文件夹(例如C:/ Boost)
  • Run bootstrap gcc 运行bootstrap gcc
  • Run b2 toolset=gcc (or whatever b2 command you need) 运行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. 如果您正在使用某些人没有明确设置工具集的示例,则必须自己添加toolset=gcc Note that toolset must be placed in the property position not the option or command position. 请注意, toolset必须放在属性位置而不是选项命令位置。 From b2 --help : 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: 因此,如果有人在编写命令以使用--prefix选项调用install命令,则会将其写为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM