Last active
August 29, 2015 14:19
-
-
Save wakita/71c8a232ee79ac34fbb5 to your computer and use it in GitHub Desktop.
MInGW-w64向けのBoostのビルド方法とそのテスト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bootstrap mingw | |
b2 install --build-type=complete --build-dir=c:\wakita\.tmp --layout=tagged cxxflags="-std=c++11" toolset=gcc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project(btest CXX) | |
cmake_minimum_required(VERSION 2.6) | |
set(Boost_DIR /Boost) | |
set(Boost_USE_STATIC_LIBS ON) | |
set(Boost_USE_MULTITHREADED OFF) | |
find_package(Boost 1.58.0 COMPONENTS system filesystem) | |
if (NOT Boost_FOUND) | |
message(SEND_ERROR "Boost not found!") | |
else() | |
include_directories(${Boost_INCLUDE_DIRS}) | |
add_executable(btest test.cpp) | |
set_property(TARGET btest PROPERTY CXX_STANDARD 11) | |
set_property(TARGET btest PROPERTY CXX_STANDARD_REQUIRED ON) | |
target_link_libraries(btest ${Boost_LIBRARIES}) | |
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
#include <boost/filesystem/fstream.hpp> | |
namespace fs = boost::filesystem; | |
int main() { | |
const fs::path base = fs::path("c:\\wakita\\build"); | |
const fs::path p = base / "file.txt"; | |
cout << string("Path is ") << p << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MinGW-w64用にBoostをビルドするのにちょっと苦労しました.はまったのは,そもそもMinGW-w64用にbootstrapする方法が公式のドキュメントに明確に書かれておらず,ネットの情報はさまざまにあってどれが正しいのか判然としなかったことにあります.今回は build-type を complete としたために,てんこ盛りになり,それぞれの機能についてライブラリが16個ずつできました.ビルドもものすごく時間がかかります.ここまでやる必要はありません.
Kくんのビルドでは filesystem に関連する演算子でエラーが出てしまったのですが,Boostのビルドでcssflagsを指定して,C++11のサポートを要求することで解消できたような気がします.
test.cppとCMakeLists.txtはKくんのEvernoteメモを参考にして作りました.