error linking boost library to cmake

I am trying to link boost library to my c++ project using cmake. Here is the cmakelists.txt file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
cmake_minimum_required(VERSION 3.2)

project(deye)

find_package(OpenCV 3 REQUIRED)
find_package(Boost 1.55 REQUIRED system serialization)
include_directories(${Boost_INCLUDE_DIR})

set(SRC main.cpp obj_rec.cpp)
add_executable(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES})

add_executable(tests test.cpp)
target_link_libraries(tests ${OpenCV_LIBRARIES} ${Boost_LIBRARIES})


Here is my main file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <map>
#include <sstream>
#include  <iostream>
#include <boost/serialization/map.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/vector.hpp>

int main()
{
   std::map<int, int> map = {{1,2}, {2,1}};
   std::stringstream ss;
   boost::archive::text_oarchive oarch(ss);
   oarch << map;
   std::map<int, int> new_map;
   boost::archive::text_iarchive iarch(ss);
   iarch >> new_map;
   std::cout << (map == new_map) << std::endl;
}


But when i build this project i'm getting below errors:
/usr/include/boost/archive/text_iarchive.hpp:117: error: undefined reference to `boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::text_iarchive_impl(std::istream&, unsigned int)'


Last edited on
you are not linking against boost libraries

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES})
(same for tests, I guess)
Topic archived. No new replies allowed.