在UBuntu 14.01中配置Boost库(及CodeBlocks)
来源:互联网 发布:天猫和淘宝有什么区别 编辑:程序博客网 时间:2024/06/05 08:01
步骤1:
首先下载Boost库。
Linux下推荐下面的链接。
http://www.boost.org/users/history/version_1_56_0.html
步骤2:配置Boost库
正如Boost库文档中说明的,Boost的大部分库以hpp文件提供,即类的声明和实现都放在同一文件中并且以源码提供,在使用时不需要做特别处理。因此,下载压缩包之后,将压缩包解压到合适路径下就可以使用它们了。在UBuntu中,推荐放置在/home或者/usr/local中的一处。例如,Boost的版本是1.56.0,那么可以将库展开到/usr/local/boost_1_56_0这个目录中。
之后,可以启动CodeBlocks,配置全局变量。具体操作为菜单Settings->Global Variable,配置信息如下。
注意:编译之前要选择工程的“Build Options”然后配置一下Boost库的查找路径。之后,按Ctrl+F9执行编译,就可以知道是否配置完毕。
确认执行结果
步骤3:编译二进制Boost库
由于Boost的配置在持续改进,使用Boost官网起步教程中的快速安装步骤,只需要3不就可以编译二进制库。
$ cd path/to/boost_1_56_0
$ ./bootstrap.sh --help
此处,先按缺省配置操作。直接指定安装路径即可,注意下面红色的参数配置,其中YOUR_BOOST_LIB_DIR是你希望的Boost二进制库安装位置,譬如,你可以使用“binlib”作为目录名称,我的例子中是按照“stage”目录设置的。我的硬盘空间很充足,也为了省事 ,是按照编译全部库进行操作(可以使用--with-libraries=lib1,lib2,...,的格式制定部分库进行编译。有关如何指定编译部分库文件的操作在CSDN上已有博文,此处不再赘述)。
以下为执行./bootstrap.sh的输出结果:
$ sudo sh ./bootstrap.sh --prefix=YOUR_BOOST_LIB_DIR
Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html
以下安装包中python2.6-dev和libbz2-dev特别重要,缺少这些库文件的支持,编译过程中python库和bzip库会无法编译。
$ sudo apt-get install python2.6-dev
$ sudo apt-get install libicu-dev
$ sudo apt-get install libbz2-dev
此步骤完成之后,就可以启动b2程序进行编译。为了确认编译的过程没有出错,建议将编译结果的输出重定向(可以使用">> build.log")到日志文件。因此,执行以下命令。(实际上,由于bjam已经过时,你即便启动bjam,也是调用b2程序。)
$ ./b2 install >build.log
如果输出到屏幕,控制台中的信息会由于内容过多,后输出的结果覆盖掉之前的输出结果。以下是编译开始时的信息摘录。
Building the Boost C++ Libraries.
Performing configuration checks
- 32-bit : no (cached)
- 64-bit : yes (cached)
- arm : no (cached)
- mips1 : no (cached)
- power : no (cached)
- sparc : no (cached)
- x86 : yes (cached)
- lockfree boost::atomic_flag : yes (cached)
- has_icu builds : no (cached)
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
- zlib : yes (cached)
- iconv (libc) : yes (cached)
- icu : no (cached)
- icu (lib64) : no (cached)
- compiler-supports-ssse3 : yes (cached)
- compiler-supports-avx2 : yes (cached)
- gcc visibility : yes (cached)
- long double support : yes (cached)
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
- zlib : yes (cached)
Component configuration:
- atomic : building
- chrono : building
- container : building
- context : building
- coroutine : building
- date_time : building
- exception : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : building
- log : building
- math : building
- mpi : building
- program_options : building
- python : building
- random : building
- regex : building
- serialization : building
- signals : building
- system : building
- test : building
- thread : building
- timer : building
- wave : building
...patience...
...patience...
...patience...
...patience...
...patience...
...found 11605 targets...
...updating 70 targets...
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/usr/local/boost_1_56_0
The following directory should be added to linker library paths:
/usr/local/boost_1_56_0/stage/lib
步骤4:确认编译结果
确认编译结果同样可以使用官方网站上提供的例子程序,
此时配置搜索路径(仍然是选择Build options在对话框中选择Search directories)就需要增加一个选项,如下图。
同时,还要配置链接库,如下图。
此时,编译例子程序遍可以成功完成。
在编译的可执行程序目录下新建一个文本文件sample.txt,粘贴以下测试信息并保存退出。
可以看到例子给的是使用正则表达式的程序,功能是在输入流中检索Subject字符串之后的内容(即主题的内容),因此输出结果是符合期望的。
最后要说的几句话:
1)如果亲的硬盘空间有限,在所有任务结束后,可以切换到刚才编译时执行的目录下,使用以下命令清理编译中间结果。中间结果存放在“bin.v2”目录中。注意:如果清理了编译中间结果,以后Boost库更新的时候,所有编译都必须从头来过。
3)本文中的所有步骤我都已经实际测试过,如果试验过程遇到其他问题可以留言。最后请大家尊重我的劳动成果,转载请注明出处。多谢!
- 在UBuntu 14.01中配置Boost库(及CodeBlocks)
- boost库在codeblocks中的配置(转载)
- 在CodeBlocks下配置Boost库
- 在CodeBlocks 开发环境中配置使用OpenCV (ubuntu系统)
- 在Ubuntu中CodeBlocks+opencv开发环境配置
- codeblocks+wxwidgets+boost搭建c++开发平台步骤||如何在CodeBlock中添加boost库文件
- 在CodeBlocks环境下使用boost库
- 在CodeBlocks环境下使用boost库
- 在CodeBlocks环境下使用boost库
- 在CodeBlocks环境下使用boost库
- 在CodeBlocks环境下使用boost库
- ubuntu中 codeblocks 下opengl的配置
- 在 ubuntu 中设置安装 boost 库
- 在windows下codeblocks中配置pthread的库
- codeblocks安装boost库
- Ubuntu 下使用OpenGL/GLUT的配置以及在Codeblocks中使用GLUT
- 在VS2005中配置boost库
- 在VS2005中配置boost库
- windows_eclipse下搭建PhoneGap环境来开发Android程序
- 类装载器
- Js New一个函数和直接调用的区别
- mysql的使用17
- Qt的许多例子
- 在UBuntu 14.01中配置Boost库(及CodeBlocks)
- 数字证书原理
- matlab 实现多维作图函数(slice)
- docker init 起步
- java.lang.OutOfMemoryError: PermGen space
- 数据结构第一章总结
- 为openwrt x86 安装gevent
- Android对话框的使用
- cocos2d-x 3.0 引用第三方库 及编译成apk时android mk文件写法