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