My CMakeLists.txt
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(test_includes)
#find_package(Boost COMPONENTS system filesystem REQUIRED)
#include_directories( ${Boost_INCLUDE_DIRS} )
set(Torch_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libtorch/share/cmake/Torch")
find_package(Boost COMPONENTS system filesystem REQUIRED)
find_package(Threads REQUIRED)
find_package(Torch REQUIRED)
find_package(yaml-cpp REQUIRED)
include_directories( ${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${yaml-cpp_INCLUDE_DIR}
${Torch_INCLUDE_DIRS}
include)
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g3 -gdwarf -fno-omit-frame-pointer -DNDEBUG")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
add_subdirectory(include)
#link_directories(libraries)
set( LIBS_TO_LINK
Domains
Agents
Planning
yaml-cpp
${TORCH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})# -llapack)
add_executable(testWarehouse testWarehouse.cpp)
target_link_libraries(testWarehouse ${LIBS_TO_LINK})
The error message i am getting:
...
[100%] Linking CXX executable testWarehouse
/usr/bin/ld: CMakeFiles/testWarehouse.dir/testWarehouse.cpp.o: in function `WarehouseSimulation(std::string const&, unsigned long)':
testWarehouse.cpp:(.text+0x13af): undefined reference to `YAML::LoadFile(std::string const&)'
/usr/bin/ld: CMakeFiles/testWarehouse.dir/testWarehouse.cpp.o: in function `YAML::detail::node_ref::set_scalar(std::string const&)':
testWarehouse.cpp:(.text._ZN4YAML6detail8node_ref10set_scalarERKSs[_ZN4YAML6detail8node_ref10set_scalarERKSs]+0x2a): undefined reference to `YAML::detail::node_data::set_scalar(std::string const&)'
/usr/bin/ld: CMakeFiles/testWarehouse.dir/testWarehouse.cpp.o: in function `YAML::Node::Scalar() const':
testWarehouse.cpp:(.text._ZNK4YAML4Node6ScalarEv[_ZNK4YAML4Node6ScalarEv]+0x79): undefined reference to `YAML::detail::node_data::empty_scalar()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/testWarehouse.dir/build.make:109: testWarehouse] Error 1
make[1]: *** [CMakeFiles/Makefile2:152: CMakeFiles/testWarehouse.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
note: i do have yamp-cpp installed
my full project:
i have tried manually adding -lyaml-cpp to the compile commands, with no effect.
can someone please check my CMakeLists.txt and tell my if am linking yaml-cpp properly, Thanks. (i am 99% sure that it is correct)
i have tried yaml-cpp versions 7.0, 6.3, 5.3 all with the same result
looking at .../build/CMakeCache.txt it includes:
//The directory containing a CMake configuration file for yaml-cpp.
yaml-cpp_DIR:PATH=/usr/share/cmake/yaml-cpp
which looks correct to me
if you need any more info please ask
Thank you
it was pre C++11 ABI issue
the solution can be found at:
https://github.com/pytorch/pytorch/issues/19353#issuecomment-652314883
I'm new to CMake and also trying to understand how linking works, or what could cause libtorch and OpenNMTTokenizer.so not work together. The former is a package with a CMake config, and the latter is a shared library.
If I remove either one of them the binary works fine, but they can't link in the same project. Maybe the headers are missing for OpenNMTTokenizer.so, but I'm not sure how to properly add them.
This is the error message:
/usr/bin/ld: CMakeFiles/example_shared.dir/src/app.cpp.o: in function `main':
app.cpp:(.text+0x292): undefined reference to `onmt::Tokenizer::joiner_marker'
/usr/bin/ld: app.cpp:(.text+0x2a7): undefined reference to `onmt::Tokenizer::Tokenizer(onmt::Tokenizer::Mode, int, std::string const&, std::string const&, std::string const&, int)'
collect2: error: ld returned 1 exit status
The program is a simple hello world just to isolate the problem:
.
│
├── CMakeLists.txt
│
├── src
│ └── app.cpp
├── include
│ └── app.h.in
│ └── app.h
├── build
#
#. Project meta
#
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
project(hello_world)
configure_file(include/app.h.in include/app.h)
#
# Add libraries
#
# 1. Torch
find_package(Torch REQUIRED PATHS /usr/local/libtorch)
# Required flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
if (Torch_FOUND)
list(APPEND LINK_LIBRARIES "${TORCH_LIBRARIES}")
else()
message(FATAL_ERROR "Cannot find libtorch")
endif()
# 2. OpenNMTTokenizer
find_library(OpenNMTTokenizer lib/libOpenNMTTokenizer.so)
if (OpenNMTTokenizer)
add_library(OpenNMTTokenizer SHARED IMPORTED lib/libOpenNMTTokenizer.so)
set_target_properties(OpenNMTTokenizer
PROPERTIES
IMPORTED_LOCATION /usr/local/lib/libOpenNMTTokenizer.so
LINKER_LANGUAGE CXX)
list(APPEND LINK_LIBRARIES OpenNMTTokenizer "${OpenNMTTokenizer_LIBRARIES}")
else()
message(FATAL_ERROR "Cannot find OpenNMTTokenizer")
endif()
#
# Add the executable
#
add_executable("${PROJECT_NAME}" src/app.cpp)
set_property(TARGET "${PROJECT_NAME}" PROPERTY CXX_STANDARD 14)
target_link_libraries("${PROJECT_NAME}" "${LINK_LIBRARIES}")
target_include_directories("${PROJECT_NAME}" PUBLIC
"${CMAKE_SOURCE_DIR}/include"
"${TORCH_INCLUDE_DIRS}")
set_target_properties("${PROJECT_NAME}"
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../bin"
)
And this is the source src/app.cpp
#include "app.h"
#include <iostream>
#include <vector>
#include <torch/torch.h>
#include <torch/script.h>
#include <onmt/Tokenizer.h>
using namespace onmt;
int main(){
torch::Tensor tensor = torch::eye(3);
std::cout << tensor << std::endl;
// It doesn't work if torch is linked
Tokenizer tokenizer(Tokenizer::Mode::Conservative, Tokenizer::Flags::JoinerAnnotate);
return 0;
}
Complete build output
/usr/local/bin/cmake -S/home/inez/Projects/cmake_hello_world -B/home/inez/Projects/cmake_hello_world/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/inez/Projects/cmake_hello_world/build/CMakeFiles /home/inez/Projects/cmake_hello_world/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/inez/Projects/cmake_hello_world/build'
make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/depend
make[2]: Entering directory '/home/inez/Projects/cmake_hello_world/build'
cd /home/inez/Projects/cmake_hello_world/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/inez/Projects/cmake_hello_world /home/inez/Projects/cmake_hello_world /home/inez/Projects/cmake_hello_world/build /home/inez/Projects/cmake_hello_world/build /home/inez/Projects/cmake_hello_world/build/CMakeFiles/hello_world.dir/DependInfo.cmake --color=
Dependencies file "CMakeFiles/hello_world.dir/src/app.cpp.o.d" is newer than depends file "/home/inez/Projects/cmake_hello_world/build/CMakeFiles/hello_world.dir/compiler_depend.internal".
Consolidate compiler generated dependencies of target hello_world
make[2]: Leaving directory '/home/inez/Projects/cmake_hello_world/build'
make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/build
make[2]: Entering directory '/home/inez/Projects/cmake_hello_world/build'
[ 50%] Linking CXX executable ../bin/hello_world
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/hello_world.dir/link.txt --verbose=1
/usr/bin/c++ -D_GLIBCXX_USE_CXX11_ABI=0 -rdynamic CMakeFiles/hello_world.dir/src/app.cpp.o -o ../bin/hello_world -Wl,-rpath,/usr/local/libtorch/lib:/usr/local/cuda-11.2/lib64/stubs:/usr/local/cuda-11.2/lib64:/usr/local/lib /usr/local/libtorch/lib/libtorch.so /usr/local/libtorch/lib/libc10.so /usr/local/libtorch/lib/libkineto.a /usr/local/cuda-11.2/lib64/stubs/libcuda.so /usr/local/cuda-11.2/lib64/libnvrtc.so -lnvToolsExt /usr/local/cuda-11.2/lib64/libcudart.so /usr/local/libtorch/lib/libc10_cuda.so /usr/local/lib/libOpenNMTTokenizer.so -Wl,--no-as-needed,"/usr/local/libtorch/lib/libtorch_cuda.so" -Wl,--as-needed -Wl,--no-as-needed,"/usr/local/libtorch/lib/libtorch_cuda_cpp.so" -Wl,--as-needed -Wl,--no-as-needed,"/usr/local/libtorch/lib/libtorch_cpu.so" -Wl,--as-needed -lpthread /usr/local/libtorch/lib/libc10_cuda.so /usr/local/libtorch/lib/libc10.so /usr/local/cuda-11.2/lib64/libcufft.so /usr/local/cuda-11.2/lib64/libcurand.so /usr/local/cuda-11.2/lib64/libcublas.so /usr/local/cuda-11.2/lib64/libcudnn.so -Wl,--no-as-needed,"/usr/local/libtorch/lib/libtorch_cuda_cu.so" -Wl,--as-needed -Wl,--no-as-needed,"/usr/local/libtorch/lib/libtorch.so" -Wl,--as-needed -lnvToolsExt /usr/local/cuda-11.2/lib64/libcudart.so
/usr/bin/ld: CMakeFiles/hello_world.dir/src/app.cpp.o: in function `main':
app.cpp:(.text+0x292): undefined reference to `onmt::Tokenizer::joiner_marker'
/usr/bin/ld: app.cpp:(.text+0x2a7): undefined reference to `onmt::Tokenizer::Tokenizer(onmt::Tokenizer::Mode, int, std::string const&, std::string const&, std::string const&, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hello_world.dir/build.make:114: ../bin/hello_world] Error 1
make[2]: Leaving directory '/home/inez/Projects/cmake_hello_world/build'
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hello_world.dir/all] Error 2
make[1]: Leaving directory '/home/inez/Projects/cmake_hello_world/build'
make: *** [Makefile:91: all] Error 2
Torch has a TorchConfig.make
# Finds the Torch library
#
# This will define the following variables:
#
# TORCH_FOUND -- True if the system has the Torch library
# TORCH_INCLUDE_DIRS -- The include directories for torch
# TORCH_LIBRARIES -- Libraries to link against
# TORCH_CXX_FLAGS -- Additional (required) compiler flags
Linked libraries from LINK_LIBRARIES
LINK_LIBRARIES=torchtorch_library/usr/local/libtorch/lib/libc10.so/usr/local/libtorch/lib/libkineto.a/usr/local/cuda-11.2/lib64/stubs/libcuda.so/usr/local/cuda-11.2/lib64/libnvrtc.so/usr/lib/x86_64-linux-gnu/libnvToolsExt.so/usr/local/cuda-11.2/lib64/libcudart.so/usr/local/libtorch/lib/libc10_cuda.soOpenNMTTokenizer
See the answer below
The libraries were linked to different standard libraries. As suggested by #botje, the value for _GLIBCXX_USE_CXX11_ABI didn't match.
I recompiled OpenNMTTokenizer with this line, then the main project compiled without errors:
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
From libstdc++
If you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace or the tag [abi:cxx11] then it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro.
This commonly happens when linking to a third-party library that was
compiled with an older version of GCC. If the third-party library
cannot be rebuilt with the new ABI then you will need to recompile
your code with the old ABI.
Read more at gnu.org
As discussed in the comments, it turns out that one of the components (OpenNMTTokenizer) was compiled WITH the CXX11 ABI, and the other two (Torch and app.cpp) were not. This caused a mismatch in symbol names.
The immediate fix was to recompile OpenNMTTokenizer without the CXX11 ABI, although the proper fix is to compile everything with the CXX11 ABI. This would mean recompiling Torch.
I'm trying to include opencv2.4.9 with cmake:
cmake_minimum_required(VERSION 2.8.3)
project(HydroCamel)
SET(CMAKE_CXX_FLAGS "-lpthread")
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
catkin_package()
set(SRC_FOLDER src/src)
set(ALOGS_FOLDER src/Algos)
set(ALOGS_UTILS_FOLDER src/Algos/Utils)
set(SRC_INCLUDE_FOLDER src/include)
set(DIRS ${SRC_FOLDER} ${ALOGS_FOLDER} ${ALOGS_UTILS_FOLDER} ${SRC_INCLUDE_FOLDER})
include_directories(${DIRS})
file(GLOB_RECURSE SRC_FILES "*.h" "*.cpp")
include_directories(include ${catkin_INCLUDE_DIRS})
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.55.0 COMPONENTS filesystem system thread)
#FIND_PACKAGE(OpenCV REQUIRED core imgproc highgui)
include_directories(${OpenCV_INCLUDE_DIRS})
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(SourceFiles ${SRC_FILES})
TARGET_LINK_LIBRARIES(SourceFiles ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(SourceFiles ${OpenCV_LIBS})
endif()
And I receive this error:
CMake Error at HydroCamel/CMakeLists.txt:28 (find_package): Found
package configuration file:
/home/jdorfsman/opencv-2.4.9/build/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered
to be NOT FOUND.
-- Configuring incomplete, errors occurred! See also "/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeOutput.log". See also
"/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeError.log".
This is the CMakeError.log file:
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec1061744568/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec1061744568.dir/build.make CMakeFiles/cmTryCompileExec1061744568.dir/build
make[1]: Entering directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o -c /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec1061744568
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1061744568.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o -o cmTryCompileExec1061744568 -rdynamic
CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec1061744568] Error 1
make[1]: Leaving directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec1061744568/fast] Error 2
File /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef pthread_create
return ((int*)(&pthread_create))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec3426763052/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3426763052.dir/build.make CMakeFiles/cmTryCompileExec3426763052.dir/build
make[1]: Entering directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3426763052.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec3426763052.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec3426763052
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3426763052.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec3426763052.dir/CheckFunctionExists.c.o -o cmTryCompileExec3426763052 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec3426763052] Error 1
make[1]: Leaving directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec3426763052/fast] Error 2
Looks like you don't specify the pthread flag.
CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec1061744568] Error 1
make[1]: Leaving directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec1061744568/fast] Error 2
try add:
SET(CMAKE_CXX_FLAGS "-lpthread")
I have two cmake files that build a directory and then try to compile an example that uses that library. The content of the first CMakeLists.txt file stored at the project root ${CMAKE_SOURCE_DIR} is:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project("lsd_point_pair")
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
#Note: Eclipse automatically picks up include paths with this on!
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_CXX_FLAGS "-g")
find_package(PCL 1.7 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
set(BOOST_LIBS program_options)
find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
MESSAGE(" Boost_LIBRARIES: ${Boost_LIBRARIES}")
include_directories(${PROJECT_BINARY_DIR})
link_directories(${PROJECT_BINARY_DIR}/lib})
add_library(lsd_obj_rec_ransac lsd_obj_rec_ransac.cpp lsd_obj_rec_ransac.h lsd_point_pair_model_library.cpp lsd_point_pair_model_library.h ndim_voxel_structure.h orr_octree_cloud.h orr_octree_cloud.cpp)
target_link_libraries(lsd_obj_rec_ransac ${PCL_LIBRARIES} ${Boost_LIBRARIES})
######## subdirectories #########
add_subdirectory(examples)
In ${CMAKE_SOURCE_DIR}/examples I have the following CMakeLists.txt file:
add_executable(example_pcl_lsd_point_pair example_pcl_lsd_point_pair.cpp)
target_link_libraries(example_pcl_lsd_point_pair lsd_obj_rec_ransac ${Boost_LIBRARIES} ${PCL_LIBRARIES})
After successfully running cmake I run make and I get the linking errors:
CMakeFiles/example_pcl_lsd_point_pair.dir/example_pcl_lsd_point_pair.cpp.o: In function `~LSDObjRecRANSAC':
make[2]: Leaving directory `/media/Data/Documents/Grad/research/Projects/LSDPointPairs/qtcreator-build'
make[1]: Leaving directory `/media/Data/Documents/Grad/research/Projects/LSDPointPairs/qtcreator-build'
/home/mustafa/projects/LSDPointPairs/examples/../lsd_obj_rec_ransac.h:44: undefined reference to `pcl::recognition::ORROctreeCloud::~ORROctreeCloud()'
/home/mustafa/projects/LSDPointPairs/examples/../lsd_obj_rec_ransac.h:44: undefined reference to `pcl::recognition::ORROctreeCloud::~ORROctreeCloud()'
../lib/liblsd_obj_rec_ransac.a(lsd_obj_rec_ransac.cpp.o): In function `LSDObjRecRANSAC':
/home/mustafa/projects/LSDPointPairs/lsd_obj_rec_ransac.cpp:18: undefined reference to `pcl::recognition::LSDPointPairModelLibrary::LSDPointPairModelLibrary(float, float, float)'
/home/mustafa/projects/LSDPointPairs/lsd_obj_rec_ransac.cpp:18: undefined reference to `pcl::recognition::ORROctreeCloud::ORROctreeCloud()'
/home/mustafa/projects/LSDPointPairs/lsd_obj_rec_ransac.cpp:18: undefined reference to `pcl::recognition::ORROctreeCloud::~ORROctreeCloud()'
../lib/liblsd_obj_rec_ransac.a(lsd_point_pair_model_library.cpp.o): In function `LSDPointPairModel':
/home/mustafa/projects/LSDPointPairs/lsd_point_pair_model_library.h:36: undefined reference to `pcl::recognition::ORROctreeCloud::ORROctreeCloud()'
/home/mustafa/projects/LSDPointPairs/lsd_point_pair_model_library.h:36: undefined reference to `pcl::recognition::ORROctreeCloud::~ORROctreeCloud()'
../lib/liblsd_obj_rec_ransac.a(lsd_point_pair_model_library.cpp.o): In function `~LSDPointPairModel':
/home/mustafa/projects/LSDPointPairs/lsd_point_pair_model_library.h:27: undefined reference to `pcl::recognition::ORROctreeCloud::~ORROctreeCloud()'
/home/mustafa/projects/LSDPointPairs/lsd_point_pair_model_library.h:27: undefined reference to `pcl::recognition::ORROctreeCloud::~ORROctreeCloud()'
collect2: ld returned 1 exit status
make[2]: *** [bin/example_pcl_lsd_point_pair] Error 1
make[1]: *** [examples/CMakeFiles/example_pcl_lsd_point_pair.dir/all] Error 2
make: *** [all] Error 2
The library successfully gets built because I see the liblsd_obj_rec_ransac.a file gets generated. But the problem happens when trying to compile the example. What am I doing wrong?
I am trying to build the hello.c example from http://www.glprogramming.com/red/chapter01.html (look for "Example 1-2").
My CMakeLists.txt is as follows:
cmake_minimum_required (VERSION 2.8)
project (GLUTEX)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIRS})
include_directories(${OpenGL_INCLUDE_DIRS})
add_executable (glutex glutex.c)
target_link_libraries (glutex ${OpenGL_LIBRARIES})
target_link_libraries (glutex ${GLUT_LIBRARIES})
The CMake call succeeds in generating the required Makefile. But when I call make, I encounter the following:
Scanning dependencies of target glutex
[100%] Building C object CMakeFiles/glutex.dir/glutex.c.o
Linking C executable glutex
/usr/bin/ld: CMakeFiles/glutex.dir/glutex.c.o: undefined reference to symbol 'glOrtho'
/usr/bin/ld: note: 'glOrtho' is defined in DSO /usr/lib64/libGL.so.1 so try adding it to the linker command line
/usr/lib64/libGL.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [glutex] Error 1
make[1]: *** [CMakeFiles/glutex.dir/all] Error 2
make: *** [all] Error 2
How do I fix this?
Try changing
target_link_libraries (glutex ${OpenGL_LIBRARIES})
to
target_link_libraries (glutex ${OPENGL_LIBRARIES})