无法使用 GCC 构建 Boost 库
我使用的是 Windows 7 64 位,并且想要从命令行编译非预编译库(具体来说,我需要文件系统)(我不使用 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,它运行了一个半小时并构建了大部分库,但不是我目前需要的库:文件系统。 尝试仅编译文件系统,使用 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
语句。
这里有什么提示吗?
I am using Windows 7 64-bit, and want to compile the non-precompiled libraries (specifically, I need Filesystem) from the command line (I do not use MSVC). I have MinGW, but read on the Boost website that MSYS shell is not supported, so I'm trying to compile the libraries from the Windows command prompt.
First of all, running bootstrap.bat results in the following error:
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.
Plus, there is not bjam.log file anywhere in the boost_root directory.
Disregarding this error, and trying to run the downloaded bjam.exe file, I get another error:
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
etc. with quite a lot of complaints. Setting the 'architecture' and 'address-model' options doesn't help.
Any suggestions?
@Andre
Following Andre's suggestion, I created minGW-bjam that was running for an hour and a half and built most of the libraries, but not the one I need at this moment: Filesystem.
Trying to compile only Filesystem, specifying version 2 with define="BOOST_FILESYSTEM_VERSION=2"
and --disable-filesystem3
does not help. I get the following error:
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"
etc. with a lot of ...failed
statements.
Any hints here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这很容易。只需使用“bootstrap.bat gcc”选择GCC
It's easy. Just use "bootstrap.bat gcc" to select GCC
引导脚本假定 msvc 编译器可用。但是您可以在没有引导脚本的情况下手动构建bjam:
进入tools\build\v2\engine\src目录并调用“build.bat mingw”。它将创建一个 bjam.exe。然后你可以把它放在你的%PATH%或可能在根boost目录中......
说实话,我通常使用msvc编译器构建bjam,并使用这个“msvc-bjam”来构建我的mingw boost库。
The bootstrap script assumes the msvc compiler is available. But you can build bjam by hand without the bootstrap script:
Step into the tools\build\v2\engine\src directory and call "build.bat mingw". It will create a bjam.exe. You can then put it in your %PATH% or perhaps in the root boost directory...
To be honest, I usually build bjam like this with the msvc compiler and use this "msvc-bjam" to build my mingw boost libraries.
所以...问题的第一部分通过安德烈的建议解决了。
第二部分是通过在所有地方将变量 BOOST_FILESYSTEM_VERSION 设置为 3 来解决的(上面的错误抱怨与文件
user.hpp
中设置的内容不兼容)。虽然这不是我正在使用的 Boost 1.45 的默认选项,但它是唯一有效的选项(即 bjam 无论如何都想编译版本 3)。所以现在我有文件系统库的版本 3,以及所有其他库的版本 2,但这目前似乎不是问题。不过,我在将 Boost 与 OpenCV 和 Eigen 库一起使用时确实遇到了问题……迎接下一个挑战;)
So... the first part of the problem was solved by Andre's suggestion.
The second part was solved by setting the variable BOOST_FILESYSTEM_VERSION to 3 everywhere (the error above complains about incompatibility with what is set in file
user.hpp
). Although this is not the default option for Boost 1.45 that I'm using, it's the only thing that works (i.e. bjam wants to compile version 3 no matter what). So now I have version 3 of the filesystem library, and version 2 for all others, but that doesn't seem to be an issue for the moment.I do have a problem with using Boost with OpenCV and Eigen libraries, though... off to the next challenge ;)
由于我还不能发表评论,我想补充一下我跑了
正确生成 b2 然后
这些包含文件将位于您的 boost 根文件夹 (boost_1_58_00/boost) 中,您的二进制文件位于指定的构建文件夹。
Since I can't comment yet, I want to add that I ran
to generate b2 properly and then
The includes will be located at your boost root folder (boost_1_58_00/boost) and your binaries at the specified build folder.