I want to use boost.asio header in my project, but when I include it's .hpp file I got this output error on compile:
I need boost.asio for crow to route my web request.
/home/john/Downloads/clion-1.2.4/bin/cmake/bin/cmake --build /home/john/.CLion12/system/cmake/generated/a3f08900/a3f08900/Release --target rcp -- -j 8 [ 50%] Linking CXX executable /home/john/projects/rightChoiceProperty/bin/rcp CMakeFiles/rcp.dir/main.cpp.o: In function
_GLOBAL__sub_I_main': main.cpp:(.text.startup+0x53): undefined reference to
boost::system::generic_category()' main.cpp:(.text.startup+0x58): undefined reference toboost::system::generic_category()' main.cpp:(.text.startup+0x5d): undefined reference to
boost::system::system_category()' main.cpp:(.text.startup+0x62): undefined reference to `boost::system::system_category()' collect2: error: ld returned 1 exit status CMakeFiles/rcp.dir/build.make:94: recipe for target '/home/john/projects/rightChoiceProperty/bin/rcp' failed make[3]: * [/home/john/projects/rightChoiceProperty/bin/rcp] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/rcp.dir/all' failed make[2]: [CMakeFiles/rcp.dir/all] Error 2 CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/rcp.dir/rule' failed make[1]: [CMakeFiles/rcp.dir/rule] Error 2 Makefile:118: recipe for target 'rcp' failed make: * [rcp] Error 2
I'm using CLion 1.2.4 as IDE this is my main.cpp content:
#include <iostream>
#include <boost/asio.hpp>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
And this is my CMakeLists.txt file content:
cmake_minimum_required(VERSION 3.3)
project(rcp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lboost_system")
set(SOURCE_FILES main.cpp)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
include_directories("libraries/boost")
add_executable(rcp ${SOURCE_FILES})
Thank you so much