1. 程式人生 > >為何windows下用cmake編譯找不到Boost庫

為何windows下用cmake編譯找不到Boost庫

問題描述:

       CMake Error at D:/CMake/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:910 (message):

       Unable to find the requested Boost libraries.

       Unable to find the Boost header files. Please set BOOST_ROOT to the root

       directory containing Boost or BOOST_INCLUDEDIR to the directory containing

       Boost's headers.

       Call Stack (most recent call first):

       CMakeLists.txt:12 (find_package)

解決方法:

一、下載Boost原始碼

二、解壓boost_1_63_0.zip到某一目錄,小編直接入在D:\下面了

       

三、編譯boost庫

      選擇自己對應的VS版本,小編本次使用VS2015編譯,其他版本的也可以。

      1、開啟VS2015的命令提示符工具,如下圖所示:

      

      2、切換到boost對應的解壓目錄:cd d:\boost\boost_1_63

      3、配置編譯環境,執行以下命令列: bootstrap --prefix="D:\boost\boost_1_63"

           prefix設定編譯生成的目錄,也可以設定成其他的,都可以

    4、編譯boost,執行以下命令:

          b2 --build-type=complete --toolset=msvc-14.0 --layout=versioned --prefix="D:\boost\boost_1_63" --without-mpi install

          以上紅色部分需要根據不同的VS版本修改,見下圖:

          

          然後靜等編譯即可,大概需要2個小時左右。

五、cmake配置boost

            

          

配置完畢,如此便不會出錯了。

Enjoy it!