1

私はC++を初めて使用し、Boostライブラリを初めてインストールして使用しようとしています。高解像度のタイミングの例をコンパイルしようとしています:

#include <boost/timer/timer.hpp>
#include <cmath>

int main()
{
   boost::timer::auto_cpu_timer t;

   for (long i = 0; i < 100000000; ++i)
      std::sqrt(123.456L); // burn some time

   return 0;
}

ただし、これをコンパイルしようとすると、Boostライブラリにアクセスできていないようです。

$ g++ -Wall -I ~/boost_1_53_0 boost_cpu_timer.cc
Undefined symbols for architecture x86_64:
    "boost::timer::auto_cpu_timer::auto_cpu_timer(short)", referenced from:
        _main in ccQSlF30.o
    "boost::timer::auto_cpu_timer::~auto_cpu_timer()", referenced from:
        _main in ccQSlF30.o
    "boost::system::generic_category()", referenced from:
        __static_initialization_and_destruction_0(int, int)in ccQSlF30.o
    "boost::system::system_category()", referenced from:
       __static_initialization_and_destruction_0(int, int)in ccQSlF30.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

提案されたコマンドでboostをインストールしました:

$ tar xzfv boost_1_53_0.tar.bz2
$ cd boost_1_53_0
$ ./bootstrap.sh --prefix=/usr/local
$ sudo ./b2 --prefix=/usr/local install

/ usr / localにいくつかのダイナミックライブラリをインストールしました。つまり、$ ls /usr/local/lib/ ... libboost_timer.a
libboost_date_time.a
libboost_timer.dylib .. ..

しかし、私はまだブーストヘッダーを使用してC++コードをコンパイルする方法を接続していません。

#include <boost/timer/timer.hpp>

どんな助けでも大歓迎です。

4

0 に答える 0