I have a C++ project using Qt with CMAKE that is organized in the following folders:
├── app
│ ├── CMakeLists.txt
│ └── main.cpp
├── CMakeLists.txt
├── include
│ └── MainWindow
│ └── MainWindow.h
└── src
├── CMakeLists.txt
├── MainWindow.cpp
└── MainWindow.ui
In the different CMakeLists.txt I have the following information:
CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
project(prj VERSION 0.0.1 LANGUAGES CXX)
add_subdirectory(app)
add_subdirectory(src)
app/CMakeLists.txt
add_executable(app main.cpp)
target_link_libraries(app PRIVATE MainWindow)
src/CMakeLists.txt
# Configure AUTO
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# Generar librería para la interfaz gráfica.
add_library(MainWindow MainWindow.cpp MainWindow.ui)
target_include_directories(MainWindow PUBLIC ../include)
target_compile_features(MainWindow PUBLIC cxx_std_14)
# Load QT files
set(CMAKE_PREFIX_PATH "/opt/Qt/5.15.2/gcc_64/lib/cmake")
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
target_link_libraries(MainWindow Qt5::Core Qt5::Gui Qt5::Widgets)
What modifications or additions do I have to make in the different CMake files so that with a similar folder distribution I can get the application to work correctly without having errors?
The exact error, after all the modificications, is the following one:
FAILED: app/app
: && /usr/bin/c++ -g app/CMakeFiles/app.dir/main.cpp.o -o app/app -Wl,-rpath,/opt/Qt/5.15.2/gcc_64/lib src/libMainWindow.a /opt/Qt/5.15.2/gcc_64/lib/libQt5Widgets.so.5.15.2 /opt/Qt/5.15.2/gcc_64/lib/libQt5Gui.so.5.15.2 /opt/Qt/5.15.2/gcc_64/lib/libQt5Core.so.5.15.2 && :
/usr/bin/ld: src/libMainWindow.a(MainWindow.cpp.o): in function `MainWindow::MainWindow(QWidget*)':
/home/developer/CLionProjects/qtTest_v0/src/MainWindow.cpp:12: undefined reference to `vtable for MainWindow'
/usr/bin/ld: /home/developer/CLionProjects/qtTest_v0/src/MainWindow.cpp:12: undefined reference to `vtable for MainWindow'
/usr/bin/ld: src/libMainWindow.a(MainWindow.cpp.o): in function `MainWindow::~MainWindow()':
/home/developer/CLionProjects/qtTest_v0/src/MainWindow.cpp:16: undefined reference to `vtable for MainWindow'
/usr/bin/ld: /home/developer/CLionProjects/qtTest_v0/src/MainWindow.cpp:16: undefined reference to `vtable for MainWindow'
Related
Installing nested libraries brings compilation errors.
I try to have a project called CROSP that contains multiple internal libraries, namely : StrainParameterisation, RodProperties, PolynomialRepresentation. These libraries are then linked to one base library : CROSP.
This one is the library that is then installed in my usr/local/...
The problem is that when I try to include the library from one external package, I get some errors saying that the compiler did not found the .so file for the internal libraries.
In the following I detail the topology of my project.
The layout of the project is the following:
.
├── cmake
│ ├── cmake_uninstall.cmake.in
│ ├── Config.cmake.in
│ └── installation_module.cmake
├── CMakeLists.txt
└── src
├── CMakeLists.txt
├── CROSP
│ └── cosserat_rod.cpp
├── include
│ └── CROSP
│ ├── CROSP
│ │ └── cosserat_rod.hpp
│ ├── polynomial_representation
│ │ └── polynomial_representation.hpp
│ ├── rod_properties
│ │ └── rod_properties.hpp
│ └── strain_parameterisation
│ └── strain_parameterisation.hpp
├── polynomial_representation
│ └── polynomial_representation.cpp
├── rod_properties
│ └── rod_properties.cpp
└── strain_parameterisation
└── strain_parameterisation.cpp
The CMakeLists are :
Top level CMakeLists
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
project(CROSP LANGUAGES CXX VERSION 2.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
find_package(Eigen3 3.4 NO_MODULE REQUIRED)
# External utilities to configure the package
include(GNUInstallDirs)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
# Give different names for debug and Release
set(CMAKE_RELEASE_POSTFIX "")
set(CMAKE_DEBUG_POSTFIX "-debug")
add_subdirectory(src)
# Install the library using the default routine
include(cmake/installation_module.cmake)
The installation_module.cmake
# Generates ${PROJECT_NAME}Config.cmake file to use our package in other projects
include(CMakePackageConfigHelpers)
configure_package_config_file(
cmake/Config.cmake.in # input template
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake # output config file
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake # where to put the config file during install
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR # paths to be used
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# Generates a config file to ensure that URL's version is checked when importing it
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
# When running make install, config files should be copied as well
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake
)
# Add the possibility tu run 'make uninstall' to remove files added via 'make install'
configure_file(
cmake/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
IMMEDIATE #ONLY
)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
The Config.cmake.in module :
#PACKAGE_INIT#
set(#PROJECT_NAME#_VERSION #PROJECT_VERSION#)
set_and_check(#PROJECT_NAME#_INCLUDE_DIRS #PACKAGE_INCLUDE_INSTALL_DIR#/#PROJECT_NAME#)
set_and_check(#PROJECT_NAME#_LIBRARY_DIR #PACKAGE_LIB_INSTALL_DIR#)
find_library(#PROJECT_NAME#_LIBRARIES NAMES #PROJECT_NAME# PATHS ${#PROJECT_NAME#_LIBRARY_DIR} NO_DEFAULT_PATH)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(#PROJECT_NAME# DEFAULT_MSG #PROJECT_NAME#_INCLUDE_DIRS #PROJECT_NAME#_LIBRARIES)
Then We have the CMakeLists in src
include_directories(include)
add_library(PolynomialRepresentation SHARED
include/${PROJECT_NAME}/polynomial_representation/polynomial_representation.hpp
polynomial_representation/polynomial_representation.cpp
)
target_link_libraries(PolynomialRepresentation
PRIVATE
Eigen3::Eigen
)
target_compile_options(PolynomialRepresentation
PRIVATE
-Wall
-Wextra
)
add_library(RodProperties SHARED
include/${PROJECT_NAME}/rod_properties/rod_properties.hpp
rod_properties/rod_properties.cpp
)
target_link_libraries(RodProperties
PRIVATE
Eigen3::Eigen
PolynomialRepresentation
)
target_compile_options(RodProperties
PRIVATE
-Wall
-Wextra
)
add_library(StrainParameterisation SHARED
include/${PROJECT_NAME}/strain_parameterisation/strain_parameterisation.hpp
strain_parameterisation/strain_parameterisation.cpp
)
target_link_libraries(StrainParameterisation
PRIVATE
Eigen3::Eigen
PolynomialRepresentation
)
target_compile_options(RodProperties
PRIVATE
-Wall
-Wextra
)
add_library(${PROJECT_NAME} SHARED
include/${PROJECT_NAME}/${PROJECT_NAME}/cosserat_rod.hpp
${PROJECT_NAME}/cosserat_rod.cpp
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Eigen3::Eigen
PUBLIC
StrainParameterisation
RodProperties
PolynomialRepresentation
)
target_compile_options(RodProperties
PRIVATE
-Werror
-Wall
-Wextra
)
add_executable(main main.cpp)
target_link_libraries(main ${PROJECT_NAME} Eigen3::Eigen)
install(
TARGETS
${PROJECT_NAME}
DESTINATION
${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY include/${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
I can run and install this library.
The following code compiles and runs fine.
#include "CROSP/CROSP/cosserat_rod.hpp"
int main(int argc, char *argv[])
{
::CROSP::polynomial_representation::PolynomialRepresentation poly(5);
::CROSP::rod_properties::MaterialProperties material(200, 100, 10);
::CROSP::CosseratRod rod(poly, material);
::CROSP::CosseratRod rod2(15);
::CROSP::CosseratRod rod3;
return 0;
}
The installation in my usr folder has the following layout
usr
└── local
├── include
│ └── CROSP
│ ├── CROSP
│ │ └── cosserat_rod.hpp
│ ├── polynomial_representation
│ │ └── polynomial_representation.hpp
│ ├── rod_properties
│ │ └── rod_properties.hpp
│ └── strain_parameterisation
│ └── strain_parameterisation.hpp
├── lib
│ ├── libCROSP-debug.so
│ └── libCROSP.so
└── share
└── CROSP
└── cmake
├── CROSPConfig.cmake
└── CROSPConfigVersion.cmake
From another project, I can include the library without problem.
Here there is an example
cmake_minimum_required(VERSION 3.5)
project(test_crosp_library LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(CROSP REQUIRED)
find_package(Eigen3 3.4 NO_MODULE REQUIRED)
add_executable(test_crosp_library main.cpp)
target_link_libraries(test_crosp_library
PUBLIC
CROSP
Eigen3::Eigen
)
And the main.cpp looks like this
#include "CROSP/CROSP/cosserat_rod.hpp"
int main()
{
::CROSP::CosseratRod rod; // errors
return 0;
}
I get the following errors
[ 50%] Linking CXX executable test_crosp_library
/usr/bin/ld: warning: libStrainParameterisation.so, needed by /usr/local/lib/libCROSP.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libRodProperties.so, needed by /usr/local/lib/libCROSP.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /usr/local/lib/libCROSP.so: undefined reference to `LieAlgebra::SE3Pose::getRotationMatrix() const'
/usr/bin/ld: /usr/local/lib/libCROSP.so: undefined reference to `CROSP::strain_parameterisation::StrainParameterisation::StrainParameterisation(CROSP::polynomial_representation::PolynomialRepresentation, unsigned int)'
/usr/bin/ld: /usr/local/lib/libCROSP.so: undefined reference to `CROSP::strain_parameterisation::StrainParameterisation::StrainParameterisation(CROSP::polynomial_representation::PolynomialRepresentation, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, unsigned int)'
/usr/bin/ld: /usr/local/lib/libCROSP.so: undefined reference to `CROSP::rod_properties::RodProperties::RodProperties(CROSP::polynomial_representation::PolynomialRepresentation)'
/usr/bin/ld: /usr/local/lib/libCROSP.so: undefined reference to `CROSP::strain_parameterisation::StrainParameterisation::updateStacks(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/test_crosp_library.dir/build.make:97: test_crosp_library] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test_crosp_library.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Can you tell what is wrong ?
Moreover, I would like to know if I can use the INTERFACE functionality in order to install the internal libraries in my usr/local with namespaces.
So the CMakeLists.txt of a package using CROSP will be:
find_package(CROSP REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
CROSP::MaterialProperties
CROSP::StrainParameterisation
)
I'm not able to link external libraries with the libraries I wrote using CMake. I'm wondering if there's something that is needed to be added to my CMakeLists.txt? Or if I need to add another CMakeLists.txt in a lower level (inside src) and what would that need to contain?
I have the following project structure:
ProjectFolder
│ ├── CMakeLists.txt
│ ├── build
│ │ └──
│ ├── include
│ │ └── helper.h
│ └── src
│ ├── helper.cpp
└── main.cpp
My CMakeList.txt is:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(object_detection)
find_package(PCL 1.5 REQUIRED)
find_package(OpenCV REQUIRED)
file(GLOB SOURCES src/*.cpp)
file(GLOB INCLUDE include/*.h)
include_directories(${PCL_INCLUDE_DIRS} ${INCLUDE})
link_directories(${PROJECT_NAME} ${PCL_LIBRARY_DIRS} ${SOURCES} )
add_definitions(${PCL_DEFINITIONS})
add_executable (${PROJECT_NAME} src/main.cpp)
target_link_libraries (${PROJECT_NAME} ${OpenCV_LIBS} ${PCL_LIBRARIES} ${SOURCES})
In my file helper.cpp I have:
#include <pcl/io/pcd_io.h>
Which gives the error:
fatal error: 'pcl/io/pcd_io.h' file not found
#include <pcl/io/pcd_io.h>
^~~~~~~~~~~~~~~~~
However I have the same include in main.cpp with no errors.
I would be very grateful for any help, please let me know if I need to clarify my question or error.
Thank you.
There are several errors in the CMakeLists.txt with the following changes the project loads appropriate libraries and builds properly. Another note is that before, to include helper.h I needed to write:
#include "../include/helper.h".
Now it works as expected with #include "helper.h".
Here is the modified CMakeLists.txt:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(object_detection)
find_package(PCL 1.5 REQUIRED)
find_package(OpenCV REQUIRED)
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp)
include_directories(${PCL_INCLUDE_DIRS} include)
link_directories(${PROJECT_NAME} ${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
#add_executable (${PROJECT_NAME} src/helper.cpp src/main.cpp )
add_executable (${PROJECT_NAME} ${SRC_FILES} )
target_link_libraries (object_detection ${PCL_LIBRARIES} ${OpenCV_LIBS})
I try to learn how to use cmake, and so I created a little project but when I try to compile I get this error : /usr/bin/ld : CMakeFiles/test.dir/main.cpp.o : dans la fonction « main » : main.cpp:(.text+0x2d) : référence indéfinie vers « la::Matrice<int>::Matrice(unsigned int, unsigned int) »
.
├── build
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── LinearAlgebra
│ └── Makefile
├── CMakeLists.txt
├── LinearAlgebra
│ ├── CMakeLists.txt
│ ├── Matrice.cpp
│ └── Matrice.hpp
└── main.cpp
./CmakeLists.txt :
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED true)
project(test_project)
add_subdirectory(LinearAlgebra)
add_executable(test main.cpp)
link_libraries(test linear_algebra)
LinearAlgebra/CMakeLists.txt :
cmake_minimum_required(VERSION 3.10)
project(linear_algebra)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(SOURCES
Matrice.cpp
)
set(HEADERS
Matrice.hpp
)
add_library(linear_algebra ${HEADERS} ${SOURCES})
Do someone know where the problem is ?
With link_libraries you define which libraries will be linked for targets that are defined after this command and within the current directory.
You probably meant to use target_link_libraries which defines libraries to link to the given target.
The documentation suggests to use this over link_libraries whenever possible. It is explicit and better scoped.
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED true)
project(test_project)
add_subdirectory(LinearAlgebra)
add_executable(test main.cpp)
target_link_libraries(test linear_algebra)
I used CMake to build my project and Catch2 to do the testing. The following is my project structure
├── build
├── CMakeLists.txt
├── compile_commands.json
├── include
│ ├── node.h
│ ├── rrt.h
│ └── tree.h
├── Makefile
├── package.xml
├── scripts
├── src
│ ├── main.cpp
│ ├── node.cpp
│ ├── rrt.cpp
│ └── tree.cpp
├── test
│ ├── CMakeLists.txt
│ └── test.cpp
└── third_party
└── catch.hpp
In ./CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(rrt_ros)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/include/rrt.h
${CMAKE_CURRENT_SOURCE_DIR}/include/tree.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node.h
${CMAKE_CURRENT_SOURCE_DIR}/src/rrt.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/tree.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
)
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
find_package(Armadillo REQUIRED)
FIND_PACKAGE(Eigen3 REQUIRED)
add_executable(
rrt
${SOURCES}
)
target_include_directories(
rrt
PUBLIC
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${ARMADILLO_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(rrt ${catkin_LIBRARIES} ${ARMADILLO_LIBRARIES})
add_subdirectory(test)
In test/CMakeLists.txt, I have
project(rrt_ros)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
find_package(Armadillo REQUIRED)
FIND_PACKAGE(Eigen3 REQUIRED)
message("TESTING......" ${CMAKE_CURRENT_SOURCE_DIR}/../include/rrt.h)
add_executable(rrt_test test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/rrt.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/tree.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/node.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/rrt.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/tree.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/node.cpp
)
target_include_directories(
rrt_test
PUBLIC
${catkin_INCLUDE_DIRS}
${Armadillo_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../include
)
target_link_libraries(
rrt_test
${catkin_LIBRARIES}
${Aramdillo_LIBRARIES}
)
In rrt.cpp, I have a function that calls armadillo's sampling function
arma::randi<arma::mat>(1, 2, arma::distr_params(1, 10))
When I compile the project, it gives me an undefined error:
rrt.cpp:(.text._ZTWN4arma23arma_rng_cxx11_instanceE[_ZTWN4arma23arma_rng_cxx11_instanceE]+0x15): undefined reference to 'arma::arma_rng_cxx11_instance'
collect2: error: ld returned 1 exit status
However, when I comment out ${CMAKE_CURRENT_SOURCE_DIR}/../src/rrt.cpp in ./test/CMakeLists.txt, it compiles fine.
I went through the same problem recently.
In your test/CmakeLists.txt, ${ARMADILLO_LIBRARIES} should be used instead of ${Aramdillo_LIBRARIES} (spelling mistake and upper case problem).
I would like to execute a working project with CLion.
So I was trying to emulate the Makefile through cmake but I'm not very good in it. I am sure that the error is inside cmake since the project is working with regular Makefile. Unfortunately, I cannot show a lot information on the project. I hope what I will show would be enough to receive your help.
The project directory structure ( without showing the files ) is shown in the following:
.
├── CMakeLists.txt
├── makefile
├── include
│ ├── data
│ ├── io
│ ├── learning
│ ├── metric
│ ├── scoring
│ └── io
└── src
├── data
├── io
├── learning
├── metric
├── scoring
├── utils
└── main.cc
./CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
project(Project)
set(DCMAKE_CXX_COMPILER "g++-5")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(Boost 1.57.0 COMPONENTS program_options system filesystem REQUIRED)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
include_directories(${Boost_INCLUDE_DIRS})
include_directories("include")
include_directories("src")
add_executable(Project src/main.cc)
target_link_libraries(Project ${Boost_LIBRARIES})
The project compiles without error, but fails during linking.
Part of the error is reported in the following:
[ 50%] Linking CXX executable Project
CMakeFiles/Project.dir/src/main.cc.o: in function "metric::ir::ir_metric_factory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int)":
./include/metric/metricfactory.h:47: undefined reference to "metric::ir::Dcg::NAME_[abi:cxx11]"
./include/metric/metricfactory.h:49: undefined reference to "metric::ir::Ndcg::NAME_[abi:cxx11]"
./include/metric/metricfactory.h:51: undefined reference to "metric::ir::Tndcg::NAME_[abi:cxx11]"
./include/metric/metricfactory.h:53: undefined reference to "metric::ir::Map::NAME_[abi:cxx11]"
CMakeFiles/Project.dir/src/main.cc.o: in function "main":
./src/main.cc:130: undefined reference to "learning::forests::LambdaMart::NAME_[abi:cxx11]"
./src/main.cc:170: undefined reference to "learning::forests::Mart::NAME_[abi:cxx11]"
./src/main.cc:171: undefined reference to "learning::forests::LambdaMart::NAME_[abi:cxx11]"
./src/main.cc:172: undefined reference to "learning::forests::ObliviousMart::NAME_[abi:cxx11]"
./src/main.cc:173: undefined reference to "learning::forests::ObliviousLambdaMart::NAME_[abi:cxx11]"
./src/main.cc:174: undefined reference to "learning::linear::CoordinateAscent::NAME_[abi:cxx11]"
./src/main.cc:175: undefined reference to "learning::forests::Project::NAME_[abi:cxx11]"
./src/main.cc:176: undefined reference to "learning::CustomLTR::NAME_[abi:cxx11]"
./src/main.cc:181: undefined reference to "metric::ir::Dcg::NAME_[abi:cxx11]"
./src/main.cc:182: undefined reference to "metric::ir::Ndcg::NAME_[abi:cxx11]"
./src/main.cc:183: undefined reference to "metric::ir::Tndcg::NAME_[abi:cxx11]"
./src/main.cc:184: undefined reference to "metric::ir::Map::NAME_[abi:cxx11]"
./src/main.cc:247: undefined reference to "metric::ir::Dcg::NAME_[abi:cxx11]"
./src/main.cc:248: undefined reference to "metric::ir::Ndcg::NAME_[abi:cxx11]"
./src/main.cc:249: undefined reference to "metric::ir::Tndcg::NAME_[abi:cxx11]"
./src/main.cc:250: undefined reference to "metric::ir::Map::NAME_[abi:cxx11]"
./src/main.cc:319: undefined reference to "learning::forests::LambdaMart::NAME_[abi:cxx11]"
./src/main.cc:324: undefined reference to "learning::forests::Mart::NAME_[abi:cxx11]"
./src/main.cc:329: undefined reference to "learning::forests::ObliviousMart::NAME_[abi:cxx11]"
./src/main.cc:334: undefined reference to "learning::forests::ObliviousLambdaMart::NAME_[abi:cxx11]"
./src/main.cc:339: undefined reference to "learning::linear::CoordinateAscent::NAME_[abi:cxx11]"
./src/main.cc:346: undefined reference to "learning::linear::CoordinateAscent::CoordinateAscent(unsigned int, double, double, unsigned int, unsigned int)"
./src/main.cc:347: undefined reference to "learning::forests::Project::NAME_[abi:cxx11]"
./src/main.cc:351: undefined reference to "learning::CustomLTR::NAME_[abi:cxx11]"
./src/main.cc:352: undefined reference to "learning::CustomLTR::CustomLTR()"
( other errors lines )
collect2: error: ld returned 1 exit status
make[2]: *** [Project] Error 1
make[1]: *** [CMakeFiles/Project.dir/all] Error 2
make: *** [all] Error 2
Ok, I solve it thanks to the help of Tsyvarev.
./CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
project(Project)
set(DCMAKE_CXX_COMPILER "g++-5")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(Boost 1.57.0 COMPONENTS program_options system filesystem REQUIRED)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
include_directories(${Boost_INCLUDE_DIRS})
include_directories("include")
file(GLOB_RECURSE SOURCES src/*.cc) #*/
add_executable(Project ${SOURCES})
target_link_libraries(Project ${Boost_LIBRARIES})
where I used file(GLOB_RECURSE SOURCES src/*.cc) to add sources instead of include_directories("src").