boost 在code blocks 中的 配置(转)
下面的至少在 boost_1_36_0和 boost_1_46_1中成功实现,boost_1_47_0中还是不行
1.
//==================================================================
// 如果要编译自己的bjam.exe (正常情况下,都需要编译自己的 bjam.exe ) 查看bjam.exe 编译,
- boost 1.36.0 的源代码压缩文件,推荐下载 7zip 版本:boost_1_36_0.7z”。
- boost 编译工具,请选择windows下的可执行文件:boost-jam-3.1.16-1-ntx86.zip (自行下载boost-jam-3.1.16-1-ntx86.zip)
//===================================================================
//============编译boost
步骤1:打开“开始”菜单,选择“运行”,输入cmd,进入控制台窗口,然后在其内通过cd命令,切换到boost安装源路径下。本例中为:
“X:\tmp\boost_1_36_0”,则过程如下:
X: (回车)
cd tmp\boost_1_36_0 (回车)
步骤2:继续上步,请在控制台内输入:
bjam --show-libraries (回车)
步骤3:正确情况下,将看到以下输出内容:
The following libraries require building:
- date_time
- filesystem
- function_types
- graph
- iostreams
- math
- mpi
- program
_options
- python
- regex
- serialization
- signals
- system
- test
- thread
- wave
步骤4:这里列出的是所有需要编译的boost模块,但我们将放弃对以下模块的编译: wave、mpi、 python、math、graph。这些模块的具体含义,大家如有需要,请自行查明。
步骤5:继续上步,在控制台内输入:
bjam install --toolset=gcc --prefix="E:\boost_1_36_0" debug --without-wave --without-mpi --without-python --without-math --without-graph (回车)
步骤6:请特别注意其中加粗部分,更换为您自己的“boost安装目标路径”。其它部分作如下说明:
步骤7:-- 是两个连续的减号,=前后均不能夹带空格,除路径之外,参数都是小写字母。
步骤8:--toolset 表示采用gcc编译。这里指的mingw32下的gcc。因此,要正确编译boost,请您一定事先已完成2.1小节中,有关Code::Blocks下mingw32环境的安装。
步骤9:debug表示我们首先编译“调试版”。
步骤10:多个 --without 指定了所要放弃编译的模块。
步骤11:回车后,控制台内将出现大量看似奇奇怪怪地文字,最后能看到以下内容,就表示成功完成本步:
...failed updating 2 targets.
...skipped 31 targets...
...updated 341 targets...
步骤12:继续上步,在控制台内输入:
bjam install --toolset=gcc --prefix="E:\boost_1_36_0" release --without-wave --without-mpi --without-python --without-math --without-graph (回车)
步骤13:改变的是“debug”更换为“release”。回车后开始发行版的boost库编译。
2. 在code blocks 中的 配置
2.1 配置boost
打开 code::blocks -> Settings -> Compiler and debugger… -> Search directory -> Add -> … [添加C:\boost\boost_1_37_0] -> OK
2.2 配置添加lib
打开 code::blocks -> Settings -> Compiler and debugger… -> Linker Settings -> Add -> … [需要什么就添加什么,例如boost\lib\boost_thread-mgw43-mt.lib]
2.3 测试boost
//简单测试,仅仅测试是否安装正确,而不是测试boost完整性
//以下程序的功能是从终端接受一个整数序列,然后乘以3再输出到终端
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | //test1.cpp #include <iostream> #include <iterator> #include <algorithm> #include <boost/lambda/lambda.hpp> int main() { using namespace boost::lambda; typedef std::istream_iterator< int > in; std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << " " ); } //以下程序在终端输出[2](2,8) //test2.cpp #include <boost/numeric/ublas/vector.hpp> #include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/io.hpp> #include <iostream> using namespace boost::numeric::ublas; int main () { vector< double > x (2); x(0) = 1; x(1) = 2; matrix< double > A(2, 2); A(0, 0) = 0; A(0, 1) = 1; A(1, 0) = 2; A(1, 1) = 3; vector< double > y = prod(A, x); std::cout << y << std::endl; return 0; } |
主要参考http://www.cnblogs.com/bylikai/archive/2011/01/15/1936293.html
http://www.cnblogs.com/bylikai/archive/2011/01/15/1936293.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述