2011-07-31 76 views
8

所以我在这里结束我的线路;我正在研究保存文件和序列化,只是为了了解C++不具备Python与其精彩的pickle一样的本地序列化能力。但幸运的是,它具有Boost功能 - 所以开始我的任务,在我的系统上安装Boost 1.47,以便能够序列化我的对象。如何使用CodeBlocks安装Boost库?

到目前为止,虽然没有成功。我第一次以为我可以使用这个: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,我得到以下错误:

Failed to build Boost.Build engine. Please consult bootstrap.log for further diagnostics.

咦 - 嗯,无处有任何形式的.log文件,但有一个名为引导一个文本文件,它包含以下内容:

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加到我的系统上!

+0

您使用的是什么工具集(编译器)? –

+0

对不起!如果我没有弄错,我正在使用MinGW,但说实话,我还没有学到很多关于编程技术的更多方面,所以我可能会误解这一点。 – GarrickW

回答

3

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

0

我试过从http://forums.codeblocks.org/index.php?topic=15164.0 &它工作很好。

BOOST安装:

或者下载的zip或升压的7zip的包。将内容提取到extract_dir。

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

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

路径minGW_dir \ BIN;%PATH%

在记事本中输入

bootstrap.exe MinGW的

打开文件EXTRACT_DIR \项目config.jam中构建升压构建系统和改变字msvc gcc。

早在命令提示符窗口中运行

b2.exe

建立加强与代码块

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

0

这里是一个博客帖子与配置代码:: Blocks的使用Boost库成交在Windows环境(头,只和编译):

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

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

bootstrap.bat mingw b2.exe

这将默认为把图书馆在舞台\ lib目录。一旦生成了所有的mingw类型库,进入Project> Build Options并通过Search Directories设置附加包含,选择Linker选项卡并设置库文件的位置,并在Linker Settings选项卡中添加必要的库名称)(例如boost_filesystem-mgw48-mt-d-1_56),应该是这样。