帮忙从源代码构建MinGW的Boost库

6
我尝试从源代码为MinGW构建Boost库。Boost网站说不能保证兼容性,但似乎有人已经成功地完成了这个任务。但我在网上找不到太多的说明。
我更新了标题以更好地反映我当前的问题。
======================== 原始帖子 ==============================
我下载了Boost 1.53.0,解压并在MinGW shell中cd到该文件夹。但我在尝试的第一步就失败了:
$ ./bootstrap.sh mingw
Building Boost.Build engine with toolset gcc...
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details

在 bootstrap.log 文件中,错误信息如下:

builtins.c:33:23: fatal error: sys/wait.h: No such file or directory
compilation terminated.
execunix.c:17:26: fatal error: sys/resource.h: No such file or directory
compilation terminated.
fileunix.c:98:17: fatal error: ar.h: No such file or directory
compilation terminated.

请帮忙!谢谢!
================== 原始内容结束,更新开始 =====================
更新:我在网上找到了这份详细的指南: http://vijay.axham.com/blog/478/building-boost-binaries-on-mingw 我按照指南进行操作,但在最后的构建步骤中卡住了。该步骤应该需要很长时间,但我收到了一个错误提示:
$ b2  --build-dir=$BOOST_BUILD_DIR --prefix=$BOOST_INSTALL_DIR toolset=gcc variant=release link=static threading=multi runtime-link=static install 2>&1 | tee $BOOST_BUILD_DIR/build.log
error: Unable to find file or target named
error:     'boost/tr1/tr1/bcc32'
error: referred from project at
error:     '.'

但目录存在(应该存在,因为它只是从压缩文件中提取出来的)。
$ ls boost/tr1/tr1/bcc32/
array.h  random.h  regex.h  tuple.h  type_tra.h  unordere.h

接近了,但仍需要帮助!谢谢!
4个回答

4

好的,我已经解决了。诀窍是从sourceforge下载tar.bz2文件而不是zip文件(具体来说是http://sourceforge.net/projects/boost/files/boost/1.53.0/)。尽管zip和tar.bz2文件都列在同一版本的Boost的同一文件夹下,但它们的内容是不同的。zip文件中缺少一些文件夹,并且压缩文件的行结束约定也不同。无论如何,我下载并提取了tar.bz2文件后,按照这里给出的说明:

http://vijay.tech/articles/wiki/Programming/Cpp/Boost/BuildingBoostOnMinGw

使用MinGW shell(确切地说是mintty)成功地从源代码构建了Boost库。有一些失败,但可能不重要:has_icu_test,has_iconv,has_icu_obj,has_icu64_obj,.masm。最后它说:

...failed updating 2 targets... ...skipped 3 targets... ...updated 10623 targets...

希望这将有助于未来的其他人。


很高兴看到我的博客文章对某人有所帮助。--干杯。 - Vijay Varadan

3
不要使用bash,通过cmd.exe构建它。
bootstrap.bat gcc

编译器可执行文件应该在系统路径中。

谢谢!有更详细的说明吗?类似这样的:http://vijay.axham.com/blog/478/building-boost-binaries-on-mingw?步骤是不是大致相同,有一个引导步骤和两个b2步骤? - astackdummy
1
@Telcom(通过suggested edit):虽然这是一个不错的答案,但应该作为一个单独的答案发布,而不是编辑到现有的答案中。 - Pokechu22

1

不要使用bash。按照下面的步骤使用cmd.exe构建:

在系统上安装MinGw。我建议采用与处理器相同的位系统。然后在系统环境中将路径设置为包含g++,...(编译器可执行文件应在PATH中)文件的bin文件夹。现在你已经准备好了。

出于明显的原因,启动一个新的终端(cmd.exe),不要使用那些不知道你的新设置的已经打开的终端。

下载boost,最新的稳定版本,解压缩它,在命令窗口中跟随路径到提取的boost的主目录。

运行此命令:bootstrap mingw

然后运行此命令,它将安装在您选择的目标文件夹中。

b2 install --prefix=c:\boost\custominstallationfolder\gcc toolset=gcc

0

如上所述,但更具体地说,我要使用gcc-mingw-4.8.1编译boost-1.54。

使用Windows shell(cmd.exe)导航到boost目录的根目录,然后执行以下操作:

bootstrap.bat gcc
b2.exe toolset=gcc

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接