无法使用GCC构建Boost库

时间:2011-03-14 13:51:36

标签: gcc boost bjam

我正在使用Windows 7 64位,并希望从命令行编译非预编译库(具体来说,我需要Filesystem)(我不使用MSVC)。我有MinGW,但在Boost网站上读到不支持MSYS shell,所以我试图从Windows命令提示符编译库。

首先,运行bootstrap.bat会导致以下错误:

Building Boost.Jam build engine 
'cl' is not recognized as an internal or external command, 
operable program or batch file. 

Failed to build Boost.Jam build engine. 
Please consult bjam.log for furter diagnostics. 

You can try to obtain a prebuilt binary from 

   http://sf.net/project/showfiles.php?group_id=7586&package_id=72941

Also, you can file an issue at http://svn.boost.org
Please attach bjam.log in that case. 

另外,boost_root目录中没有bjam.log文件。

忽略此错误,并尝试运行下载的bjam.exe文件,我收到另一个错误:

c:/boost_1_45_0/tools/build/v2/build\configure.jam:145: in builds-raw
*** argument error
* rule UPDATE_NOW ( targets * : log ? : ignore-minus-n ? )
* called with: ( <pbin.v2\libs\regex\build\gcc-mingw-4.5.2\debug\address-model64\architecture-x86>has_icu.exe :  : ignore-minus-n : ignore-minus-q )
* extra argument ignore-minus-q
(builtin):see definition of rule 'UPDATE_NOW' being called
c:/boost_1_45_0/tools/build/v2/build\configure.jam:179: in configu
re.builds
c:/boost_1_45_0/tools/build/v2/build\configure.jam:216: in object(
check-target-builds-worker)@409.check

等。有很多抱怨。设置“架构”和“地址模型”选项无济于事。

有什么建议吗?

@Andre

根据Andre的建议,我创建了运行了一个半小时的minGW-bjam并构建了大部分库,但不是我现在需要的库:Filesystem。 尝试仅编译文件系统,使用define="BOOST_FILESYSTEM_VERSION=2"--disable-filesystem3指定版本2没有帮助。我收到以下错误:

gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-4.5.2\debug\v3\src\operations.o
In file included from ./boost/filesystem/v3/operations.hpp:24:0,
             from libs\filesystem\v3\src\operations.cpp:48:
./boost/filesystem/v3/config.hpp:16:5: error: #error Compiling Filesystem version 3 
file with BOOST_FILESYSTEM_VERSION defined != 3
libs\filesystem\v3\src\operations.cpp:647:26: warning: 
'<unnamed>::create_symbolic_link_api' defined but not used

"g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -
DBOOST_FILESYSTEM_DYN_LINK=1 -DBOOST_FILESYSTEM_VERSION=2 -DBOOST_SYSTEM_DYN_LINK=1  -
I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-4.5.2\debug\v3\src\operations.o"  
"libs\filesystem\v3\src\operations.cpp"

等。有很多...failed个陈述。

这里有任何提示吗?

4 个答案:

答案 0 :(得分:29)

这很容易。只需使用“bootstrap.bat gcc”选择GCC

即可

答案 1 :(得分:9)

引导脚本假定msvc编译器可用。但是你可以在没有引导脚本的情况下手动构建bjam:

进入tools \ build \ v2 \ engine \ src目录并调用“build.bat mingw”。它将创建一个bjam.exe。然后,您可以将它放在%PATH%中,或者可能放在root boost目录中......

老实说,我通常使用msvc编译器构建这样的bjam并使用这个“msvc-bjam”来构建我的mingw boost库。

答案 2 :(得分:2)

所以...问题的第一部分是由安德烈的建议解决的。 第二部分是通过将变量BOOST_FILESYSTEM_VERSION设置为3来解决的(上面的错误抱怨与文件user.hpp中设置的不兼容)。虽然这不是我正在使用的Boost 1.45的默认选项,但它是唯一可行的(即bjam想要编译版本3,无论如何)。所以我现在拥有文件系统库的第3版,以及所有其他版本的第2版,但目前这似乎不是问题。

我确实在使用Boost与OpenCV和Eigen库时遇到了问题,但是......接下来的挑战;)

答案 3 :(得分:0)

由于我还没有发表评论,我想补充说我跑了

  

bootstrap mingw

正确生成b2然后

  

b2 --build-dir =“c:\ boost_release”toolset = gcc --build-type = complete“c:\ boost_release \ stage”

包含将位于您的boost根文件夹(boost_1_58_00 / boost)和您指定的构建文件夹中的二进制文件。

相关问题