Qt 编译boost

Qt为4.6.二、Boost为1.63.0。ios

一、安装qt-sdk-win-opensource-2010.02.1.exe。函数

二、下载boost_1_63_0并解压,如:解压到E盘根目录下。测试

三、在开始菜单中找到Qt下的Qt Command Prompt,运行。ui

四、输入命令->E:spa

五、输入命令->cd boost_1_63_0/tools/build/src/engine。orm

六、输入命令->build.bat gcc,在当前目录将会生成bin.ntx86文件夹,里面包含两个exe文件b2.exe,bjam.exe。ci

七、将bin.ntx86\bjam.exe拷贝到E:\boost_1_63_0。qt

八、输入命令->cd ../../../..,进入boost_1_63_0目录下。string

九、输入命令->bjam "toolset=gcc" install,等待一段时间后,会在C盘根目录下生成一个boost文件夹,里面放着生成的头文件以及LIB和DLL文。it

十、将C:\Boost\include\boost-1_63目录下的boost文件夹拷贝到C:\MinGW\include下面(根据MinGW安装路径来决定)。

十一、将C:\Boost\lib下的lib文件拷贝到C:\MinGW\lib下面(根据MinGW安装路径来决定)。

 

测试代码:

建一个Qt 空工程,添加一个空的main.cpp文件。

#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;  

}  

 

在pro中添加,

LIBS += -LC:\mingw\lib -lboost_system-mgw44-mt-d-1_63 -lboost_filesystem-mgw44-mt-d-1_63运行效果以下

 

-----测试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"  

相关文章
相关标签/搜索