zoukankan      html  css  js  c++  java
  • Qt 编译boost

    Qt为4.6.2、Boost为1.63.0。

    1、安装qt-sdk-win-opensource-2010.02.1.exe。

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

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

    4、输入命令->E:

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

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

    7、将bin.ntx86jam.exe拷贝到E:oost_1_63_0。

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

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

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

    11、将C:Boostlib下的lib文件拷贝到C:MinGWlib下面(根据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:mingwlib -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"  

  • 相关阅读:
    Asp.net2.0页面执行顺序
    [转帖]常用的SQL语句
    [转帖]黑客技术经典问题FAQ
    面试的一些心得
    较全的正则表达式
    很好的创业建议
    [转帖]如何让菜单项与工具栏按钮对应
    源码下载网站
    [转帖]一段测试代码
    GOF设计模式趣解(23种设计模式) <转自百度空间>
  • 原文地址:https://www.cnblogs.com/zhangnianyong/p/6546712.html
Copyright © 2011-2022 走看看