windows-qt 使用mingw编译c++boost并使用
一、boost是一个准标准库,相当于STL的延续和扩充,它的设计理念和STL比较接近,都是利用泛型让复用达到最大化。不过对比STL,boost更加实用。STL集中在算法部分,而boost包含了不少工具类,可以完成比较具体的工作。考虑到boost的强大,为此特地里做了windows下移植编译操作。
二、boost的移植
1.下载boost源码boost_1_62_0.7z,下载地址:https://sourceforge.NET/projects/boost/
其实也可以下载boos编译好的库和头文件,不过为了不必要的麻烦,建议手动编译
2.编译boost
1)解压boost到d盘,目录为boost_1_62
2)生成bjam工具:
进入D:\boost_1_62_0\boost_1_62_0\tools\build\src\engine目录下,执行build.sh gcc,在当前目录将会生成bin.ntx86文件夹,里面包含两个exe文件b2.exe,bjam.exe
3)将bin.ntx86\bjam.exe拷贝到boost1.37的解压目录D:\boost_1_62_0\boost_1_62_0中
4)进入路径D:\boost_1_62_0\boost_1_62_0,执行 bjam "toolset=gcc" install ,等待一段时间后,会在C盘根目录下生成一个boost文件夹,里面放着生成的头文件以及LIB和DLL文
5)将C:\Boost\include\boost-1_37目录下的boost文件夹拷贝到C:\MinGW\include下面
6)将C:\Boost\lib下的lib文件拷贝到C:\MinGW\lib,将C:\Boost\lib下的dll文件拷贝到C:\MinGW\bin
三、boost的使用
程序代码入下:
- #include <iostream>
- #include <boost/math/special_functions/acosh.hpp>
- #include <boost/math/special_functions/bessel.hpp>
- #include <string>
- #include <boost/filesystem.hpp>
- #include <boost/timer.hpp>
- using namespace boost::math;
- using namespace boost::math::detail;
- namespace fs = boost::filesystem;
- //测试boost贝塞尔函数
- void testBessel(){
- std::cout<<"Test Boost:"<<std::endl;
- std::cout<<acosh(2.5)<<std::endl;
- std::cout<<bessel_i0(3.2)<<std::endl;
- std::cout<<"Test Finished!"<<std::endl;
- }
- //测试boost文件系统库
- void testFileSystem(){
- fs::path full_path("c:");
- fs::directory_iterator end_iter;
- for ( fs::directory_iterator dir_itr( full_path ); dir_itr != end_iter; ++dir_itr )
- {
- std::cout << dir_itr->path().filename() << std::endl;
- }
- }
- int main(int argc, char *argv[])
- {
- std::cout << "-----测试boost贝塞尔函数-------" << std::endl;
- testBessel();
- std::cout << "-----测试boost文件系统库------" << std::endl;
- testFileSystem();
- return 0;
- }
在xxx_pro中添加,
LIBS += -LC:\Qt\mingw\lib -lboost_system -lboost_filesystem
运行效果如下,
- Starting D:\Documents\build-cplusplusboost-unknown-Debug\debug\cplusplusboost.exe...
- -----测试boost贝塞尔函数-------
- Test Boost:
- 1.5668
- 5.74721
- Test Finished!
- -----测试boost文件系统库------
- "$RECYCLE.BIN"
- "Boost"
- "Boot"
- "bootmgr"
- "Documents and Settings"
- "PerfLogs"
- "Program Files"
- "Program Files (x86)"
- "ProgramData"
- "Qt"
- "RECYCLER"
- "System Volume Information"
- "Users"
- "Windows"
http://blog.csdn.net/xiaopangzi313/article/details/52800799
windows-qt 使用mingw编译c++boost并使用的更多相关文章
- 手把手教你在Windows下使用MinGW编译libav(参考libx264的编入)
转自:http://www.th7.cn/Program/cp/201407/242762.shtml 手把手教你在Windows下使用MinGW编译libav libav是在Linux下使用纯c语言 ...
- Windows+QT+Eclipse+MinGW搭建QT开发环境详细教程
Windows+QT+Eclipse+MinGW搭建QT开发环境详细教程 一.准备工具: QT-SDK for Windows:http://get.qt.nokia.com/qtsdk/qt-sd ...
- qt用mingw编译时报错 multiple definition of
网上相关回答不少,但过于简单,这里做一下记录. qt用mingw编译程序时报“multiple definition of …”这个错误,错误信息大概是如下图所示: 1 2 3 首先,检查自己的程序是 ...
- Windows 系统 vs2012 MinGW 编译ffmpeg 静态库
Windows系统下 vs2012编译ffmpeg 动态库 前面已经有文章讲述,本文将讲述如果编译生成ffmpeg静态库以方便 在vs2012下调用. 准备工作:安装MinGW环境,修改ffmpeg配 ...
- 在Windows中使用MinGW编译X264
转自:http://www.cnblogs.com/xiongjiaji/archive/2012/06/08/2541265.html 参考:http://ayobamiadewole.com/Bl ...
- Windows下用Mingw编译Boost.Regex库
下载Boost库,解压. 定位到regex库文件夹下. GCC所对应的MAKEFILE为gcc.mak 进入命令提示符下,输入make -f gcc.mak 这是如果直接按回车执行的话,会出现错误: ...
- 在Windows下利用MinGW编译FFmpeg
目录 [隐藏] 1 环境与软件 2 第一步:安装MinGW 3 第二步:配置编译环境 4 第三步:配置SDL 5 第四步:编译 5.1 编译faac 5.2 编译fdk-aac 5.3 编译x264 ...
- Windows下使用MINGW编译ffplay
之前考虑到需要快速配置编译ffplay,使用了比较暴力的方法,具体可以参考编译ffplay.exe简化版. 这里介绍下相对规范的做法. 前提:已经安装了Windows下GCC开发环境--MINGW+m ...
- 再次尝试windows下msys+MinGW编译ffmpeg
电脑上安装太多的开源库,环境变量里面一些常用的头文件都有几种,以前使用的编译ffmpeg的方法现在常常提示错误.从config.log中看,这些错误往往都是一些头文件引用错误导致.由于项目中继续编译自 ...
随机推荐
- WCF客户端C#代码 配置config文件
不多说了,直接上代码吧.... 服务端Web.config文件中bindings配置 <bindings> <wsHttpBinding> <binding name=& ...
- Ubuntu server使用命令行上板VPNclient
Ubuntu server使用命令行上板VPNclient VPN,虚拟专用网络,这个技术还是非常有用的.近期笔者參与的项目中就使用上了VPN,大概情况是这种.有两个开发团队,在异地,代码服务器在深圳 ...
- jQuery分离构造器
http://www.imooc.com/code/3401 通过new操作符构建一个对象,一般经过四步: A.创建一个新对象 B.将构造函数的作用域赋给新对象(所以this就指向了这个新对象) ...
- centos 7 构造iptables开放80port
centos7默认是使用firewalld托管防火墙. 安装后centos7后,已安装nginxserver,但同样没有在一个局域网访问,我哥哥告诉我,我应该是一个防火墙以打开.防火墙关闭就可以了. ...
- Visual Studio 2012以后无法保存只读文件的问题
https://stackoverflow.com/questions/12497216/visual-studio-2012-will-not-save-overwrite-read-only-fi ...
- Entity Framework加载数据的三种方式。
MSDN文章Loading Related Entities 有 Eagerly Loading Lazy Loading Explicitly Loading 三种方式. 而看到查询中包含Inclu ...
- Leetcode dfs Combination Sum
Combination Sum Total Accepted: 17319 Total Submissions: 65259My Submissions Given a set of candidat ...
- wpf XMAL中隐藏控件
原文:wpf XMAL中隐藏控件 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/a771948524/article/details/9264569 ...
- wpf无边框窗体移动和大小调整
原文:wpf无边框窗体移动和大小调整 using System; using System.Windows; using System.Windows.Interop; namespace Wpf ...
- crawler_正则表达式零宽断言
在使用正则表达式时,有时我们需要捕获的内容前后必须是特定内容,但又不捕获这些特定内容的时候,零宽断言就起到作用了. (?=exp):零宽度正预测先行断言,它断言自身出现的位置的后面能匹配表达式exp. ...