0

When I run make I get this output. How do I link the g2o library using cmake. CMake doesn't have an issue writing build files.

[  7%] Linking CXX executable proj1
/usr/bin/ld: cannot find -lg2o_core_d
/usr/bin/ld: cannot find -lg2o_types_slam3d_d
/usr/bin/ld: cannot find -lg2o_solver_csparse_d
/usr/bin/ld: cannot find -lg2o_stuff_d
/usr/bin/ld: cannot find -lg2o_csparse_extension_d
/usr/bin/ld: cannot find -lg2o_types_sba_d
collect2: error: ld returned 1 exit status
CMakeFiles/proj1.dir/build.make:425: recipe for target 'proj1' failed
make[2]: *** [vo] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/proj1.dir/all' failed
make[1]: *** [CMakeFiles/proj1.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Here is my CMakeLists.txt file

cmake_minimum_required(VERSION 3.0)
project(proj1)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES
        include1.hpp
        include2.hpp
        include3.hpp)

find_package( OpenCV REQUIRED )
find_package( Eigen3 REQUIRED )
include_directories( include ${OpenCV_INCLUDE_DIRS} )
include_directories( include ${Eigen_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
add_executable( proj1 ${SOURCE_FILES} )
target_link_libraries( proj1
        ${OpenCV_LIBS}
        ${Eigen_LIBS}

         g2o_core_d
         g2o_types_slam3d_d
         g2o_solver_csparse_d
         g2o_stuff_d
         g2o_csparse_extension_d
         g2o_types_sba_d

         g2o_core
         g2o_types_slam3d
         g2o_solver_csparse
         g2o_stuff
         g2o_csparse_extension
         g2o_types_sba

        )
Airfield20
  • 254
  • 1
  • 2
  • 13
  • 1
    Possible duplicate of [CMake link to external library](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library) – Tsyvarev Oct 16 '17 at 07:17
  • Not a duplicate of that question. I know how to link libraries usually. It's not working in this case. – Airfield20 Oct 24 '17 at 11:01
  • However, the first answer to the reffered question suggests to use `link_directories()` command with the path, where libraries are located. This would eliminate the error you get. – Tsyvarev Oct 24 '17 at 12:01

0 Answers0