我试图从here运行示例代码。
我已经使用
安装了boost库sudo apt-get install libboost-all-dev
我已将它包含在我的项目中:
QMAKE_CXXFLAGS += -std=c++0x -pthread
LIBS += -lpthread
LIBS += -lboost_system
(使用QtCreator)。
但我仍然收到以下错误消息:
/usr/lib/x86_64-linux-gnu/qt5/bin/qmake -spec linux-g++-64 CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../websocket/websocket.pro
g++ -m64 -o websocket main.o -lpthread -lboost_system
main.o: In function `websocketpp::random::random_device::int_generator<unsigned int, websocketpp::concurrency::basic>::~int_generator()':
/home/alex/C++/build-websocket-Desktop-Debug/../websocket/websocketpp/random/random_device.hpp:53: undefined reference to `boost::random::random_device::~random_device()'
main.o: In function `websocketpp::random::random_device::int_generator<unsigned int, websocketpp::concurrency::basic>::int_generator()':
/home/alex/C++/build-websocket-Desktop-Debug/../websocket/websocketpp/random/random_device.hpp:60: undefined reference to `boost::random::random_device::random_device()'
/home/alex/C++/build-websocket-Desktop-Debug/../websocket/websocketpp/random/random_device.hpp:60: undefined reference to `boost::random::random_device::~random_device()'
main.o: In function `boost::asio::detail::chrono_time_traits<boost::chrono::steady_clock, boost::asio::wait_traits<boost::chrono::steady_clock> >::now()':
/usr/include/boost/asio/detail/chrono_time_traits.hpp:45: undefined reference to `boost::chrono::steady_clock::now()'
main.o: In function `unsigned int boost::random::detail::generate_uniform_int<boost::random::random_device, unsigned int>(boost::random::random_device&, unsigned int, unsigned int, mpl_::bool_<true>)':
/usr/include/boost/random/uniform_int_distribution.hpp:66: undefined reference to `boost::random::random_device::operator()()'
/usr/include/boost/random/uniform_int_distribution.hpp:114: undefined reference to `boost::random::random_device::operator()()'
/usr/include/boost/random/uniform_int_distribution.hpp:201: undefined reference to `boost::random::random_device::operator()()'
collect2: error: ld returned 1 exit status
make: *** [websocket] Error 1
15:41:25: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project websocket (kit: Desktop)
When executing step 'Make'
15:41:25: Elapsed time: 00:00.
websocketpp库似乎也存在问题,但我认为它们也基于boost。
谢谢!
答案 0 :(得分:2)
您还需要:
LIBS+=-lboost_random