Ubuntu 14.04のQT作成者でC++ Boostライブラリを使用したいと思っています。UbuntuのQT作成者のBoostライブラリの使い方14.04
私が使ってBoostライブラリをインストール:
sudo apt-get install libboost-all-dev
Boostライブラリがディレクトリにインストールされます。ここでは
/usr/include/boost
は私のmain.cppにある
#include <QCoreApplication>
#include<iostream>
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
boost::asio::steady_timer timer_;
timer_.expires_from_now(1000);
return a.exec();
}
でも私。プロファイル:
QT += core
QT -= gui
CONFIG += c++11
TARGET = test_boost_lib_in_QT
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/include/boost
LIBS += -L/usr/include/boost -lboost_system
LIBS += -L/usr/include/boost -lboost_chrono
LIBS += -L/usr/include/boost -lboost_thread
LIBS += -L/usr/include/boost -lboost_timer
の
コンパイルエラーは以下のとおりです。(私は "CTRL + B" を使用してQTから直接コンパイル)
/home/ndn-experiment/Desktop/test_boost_lib_in_QT/main.cpp:13: error: no matching function for call to 'boost::asio::basic_waitable_timer<std::chrono::_V2::steady_clock>::basic_waitable_timer()'
boost::asio::steady_timer timer_;
^
/home/ndn-experiment/Desktop/test_boost_lib_in_QT/main.cpp:14: error: no matching function for call to 'boost::asio::basic_waitable_timer<std::chrono::_V2::steady_clock>::expires_from_now(int)'
timer_.expires_from_now(1000);
^
私は何をすべき?あなたはコンストラクタにio_service
を渡す必要があるため
first - asioにはio_serviceが必要です。 steady_timerのデフォルトコンストラクタはありません。 second - expires_from_nowは、パラメータとしてdurationを必要とします。 intパラメータのオーバーロードはありません。 – stefan