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"