LoginSignup
11
13

More than 5 years have passed since last update.

boostのインストール(windows)

Posted at

こちらを参考に進めた。

環境

  • windows8.1(64bit)
  • Visual Studio Community 2017
  • cmake 3.9.0

手順

  1. 公式から最新のソースをダウンロードする。 今回はboost_1_69_0.zipを使用した。
  2. .zipを展開する。場所は適当。今回はC/boost_1_69_0に置いた。
  3. TypeScriptが必要なので、visual studio インストーラ -> 変更 -> 個別のコンポーネント -> TypeScript 2.2 SDKでインストールする。
  4. 管理者権限でPowerShellを起動して、展開したフォルダに移動して、次を実行。
PowerShell
./bootstrap.bat

Building Boost.Build engine
Bootstrapping is done. To build, run:
.\b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
.\b2 --help
- Getting started guide:
http://boost.org/more/getting_started/windows.html
- Boost.Build documentation:
http://www.boost.org/build/doc/html/index.html

さらに次を実行。

PowerShell
./b2 install --prefix="C:\local\boost_1_69_0" -j 4

筆者のマシンが4コアなので-j 4
これでC:\local\boost_1_69_0にインストールされる。

  • 本当は生成されるファイルの種類(x86とx64)でインストール先フォルダを分けたほうが良いのだと思う。上記は全部同じフォルダに入る。
  • ./b2のオプションにruntime-link=static,sharedが入っていると失敗するようだったので、できるだけ簡単なコマンドで試した。これで良いのか分からないが、とりあえず動いたものをメモ。

インストールされたことを確認

こちらと同じように検証した。下記のソースコードも同じものを使用させて頂いた。

  1. VisualStudio2017で新規にwin32コンソールアプリケーションのプロジェクト作成
  2. プロジェクトのプロパティから、C/C++ ⇒ 全般 ⇒ 追加のインクルードディレクトリC:\local\boost_1_69_0\include\boost-1_69を追加
  3. リンカー ⇒ 全般 ⇒ 追加のライブラリディレクトリC:\local\boost_1_69_0\libを追加
#include <iostream>
#include <boost/version.hpp>

int main() {
    std::cout << "boostバージョン:" << BOOST_VERSION << std::endl;
    std::cout << "boostライブラリバージョン:" << BOOST_LIB_VERSION << std::endl;
    return 0;
}

boostバージョン:106900
boostライブラリバージョン:1_69

#include <iostream>
#include <boost/asio.hpp>

namespace asio = boost::asio;
using asio::ip::tcp;

int main()
{
    //宣言
    asio::io_service io_service;
    tcp::socket socket(io_service);
    boost::system::error_code error;

    //接続
    socket.connect(tcp::endpoint(asio::ip::address::from_string("192.168.0.1"), 31400), error);

    //エラーかどうかチェック
    if (error) std::cout << "未接続: " << error.message() << std::endl;
    else std::cout << "接続済み" << std::endl;
}

未接続: 接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。

問題なくインストールされているようだ。

11
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
13