I want to make a small application for an r200 camera. It uses C++ and it needs to use the librealsense library as well as the glfw3 library.
Previously I was trying to compile this program through the command line using something like:
g++ -std=c++11 pointcloud.cpp `pkg-config --cflags glfw3` -lrealsense -lopencv_core -lopencv_imgproc -lopencv_highgui -o ir `pkg-config --static --libs glfw3` && ./ir
However, I had the misfortune of having this not work (it still failed as it couldn't find the glfw3 methods). And if I removed the --static
tag I received this error:
/usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libglfw3.a(posix_thread.c.o): undefined reference to symbol 'pthread_key_delete@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status
However, none of the suggested methods seemed to work for me.
So I have decided to try and make a CMakeLists.txt file to tackle this. What I currently have is:
cmake_minimum_required(VERSION 3.10)
project(main)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "-pthread")
find_package(OpenGL REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${OpenCV_INCLUDE_DIRS})
add_subdirectory(librealsense)
add_executable(main pointcloud.cpp librealsense/examples/example.hpp)
target_link_libraries(main ${OpenCV_LIBS})
target_link_libraries(main ${OPENGL_gl_LIBRARY})
target_link_libraries(main realsense2)
However this doesn't work and unfortunately it takes about half an hour to make since its building the librealsense module. What I was hoping for was that there'd be something like this:
cmake_minimum_required(VERSION 3.10)
project(main)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS " -pthread ")
find_package(OpenGL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(librealsense REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${librealsense_INCLUDE_DIRS})
add_executable(main pointcloud.cpp librealsense/examples/example.hpp)
target_link_libraries(main ${OpenCV_LIBS})
target_link_libraries(main ${OPENGL_gl_LIBRARY})
target_link_libraries(main ${librealsense_LIBRARY})
However I can't find anything and this doesn't work since I don't know where to get the correct library names from. I managed to snag the OPENGL names from here. But I don't know where to find the librealsense ones. If it matters I'm using a legacy branch as well as the r200 is no longer supported.
If anyone could help me with either the Makefile or the command line, that would be great as I'm having a tough time figuring this all out.