繁体   English   中英

如何使用CodeBlocks安装Boost库?

[英]How to install Boost libraries with CodeBlocks?

所以我在这里结束了我的路线; 我正在研究保存文件和序列化,只是为了了解C ++没有那种具有其精彩pickle Python本机序列化能力。 但幸运的是,它有Boost - 所以我开始在我的系统上安装Boost 1.47,以便能够序列化我的对象。

到目前为止,没有成功。 我首先想到我可以使用它: http//wiki.codeblocks.org/index.php?title = BoostWindowsQuickRef ,但我不断发现版本错误不匹配,并且在尝试多次找到与1.47兼容的Boost Jam之后(我只发现1.3.19,似乎是为1.46而建的),我看到这个页面已经过了一年半了。

然后,经过多次搜索,我在这里指出: http//www.boost.org/doc/libs/1_47_0/doc/html/bbv2/installation.html 但这也不起作用。 运行\\ bootstrap.bat时,我收到以下错误:

无法构建Boost.Build引擎。 请参阅bootstrap.log以获取进一步的诊断信息。

嗯 - 好吧,没有任何类型的.log文件,但有一个名为bootstrap的文本文件,其中包含以下内容:

Setting environment for using Microsoft Visual Studio 2010 x86 tools.
###
### Using 'vc10' toolset.
###

c:\Program Files (x86)\CodeBlocks\MinGW\downloaded\boost_1_47_0\tools\build\v2\engine>if exist bootstrap rd /S /Q bootstrap 

c:\Program Files (x86)\CodeBlocks\MinGW\downloaded\boost_1_47_0\tools\build\v2\engine>md bootstrap 

c:\Program Files (x86)\CodeBlocks\MinGW\downloaded\boost_1_47_0\tools\build\v2\engine>cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib /Febootstrap\jam0  command.c compile.c debug.c execnt.c expand.c filent.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c newstr.c option.c output.c parse.c pathunix.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c md5.c pwd.c class.c w32_getreg.c native.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c 
command.c
compile.c
debug.c
execnt.c
execnt.c(29) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
expand.c
filent.c
glob.c
hash.c
hdrmacro.c
headers.c
jam.c
jam.c(581) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
jambase.c
jamgram.c
lists.c
make.c
make1.c
newstr.c
option.c
output.c
parse.c
Generating Code...
Compiling...
pathunix.c
pathunix.c(275) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
regexp.c
rules.c
scan.c
search.c
subst.c
timestamp.c
variable.c
modules.c
strings.c
filesys.c
builtins.c
md5.c
pwd.c
class.c
w32_getreg.c
w32_getreg.c(18) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
native.c
set.c
path.c
regex.c
Generating Code...
Compiling...
property-set.c
sequence.c
order.c
Generating Code...

现在,我真的很困惑。 我已经完成了所有这些 - 我仍在编写侧卷轴,并且现在只有几个月的C ++能力。 我不知道我做错了什么。 有人能指出我一个清晰,完整的分步指南或什么? 我只想把Boost加到我的系统上!

从您发布的错误消息我假设您正在使用某些版本的Visual Studio。 要从命令行使用其编译器,您需要定义一些环境变量。 如果您使用Visual Studio命令提示符,则会自动完成此操作。 更好的是,你可能想尝试并遵循本教程

我尝试从http://forums.codeblocks.org/index.php?topic=15164.0跟随它并且它工作得非常好。

提升安装:

下载zip或7zip包的boost。 将内容解压缩到extract_dir。

打开命令提示符(cmd.exe)并导航到extract_dir。 cd extract_dir

如果minGW \\ bin文件夹(可以在CodeBlocks installatoin文件夹中找到)不在路径变量中添加它。

路径minGW_dir \\ bin;%path%

通过输入构建boost构建系统

bootstrap.exe mingw

在记事本中打开文件extract_dir \\ project-config.jam并将单词msvc更改为gcc。

回到命令提示符窗口,运行

b2.exe

使用CODEBLOCKS设置提升

使用extract_dir作为基础创建全局变量boost。 (这是我计算机上的C:\\ Libraries \\ boost_1_47_0。)其他字段不需要任何内容​​(除了可能是lib;如果在构建boost时使用自定义目录,请将路径放在此处)。 接下来(假设您正在启动一个项目,而不是添加到现有项目中),创建一个新项目(控制台应用程序应该没问题)在这个项目中,打开Project-> Build options ...并确保整个名称在左侧列中选择项目(例如,boost_test)。 切换到“搜索目录”选项卡,然后单击“添加”(对于“编译器”选项卡)。 在框中,键入$(#boost)并单击“确定”。

这是一篇博文,介绍如何配置Code :: Blocks以在Windows环境中使用Boost库(仅限标题和已编译):

http://www.technical-recipes.com/2014/configuring-codeblocks-to-use-the-boost-libraries/

不要忘记,对于需要额外编译的Boost库,您需要通过Boost根目录运行boostrap.bat和b2.exe命令:

bootstrap.bat mingw b2.exe

这将默认将库放在stage \\ lib目录中。 生成所有mingw类型库后,进入项目>构建选项并通过搜索目录设置其他包含,选择链接器选项卡并设置库文件的位置,并在链接器设置选项卡中添加必要的库名称(s )(例如boost_filesystem-mgw48-mt-d-1_56),应该是它。

暂无
暂无

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

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