簡體   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