0

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.

Dale Baker
  • 329
  • 1
  • 3
  • 14
  • 1
    "And if i removed the --static tag I received this error: ..." - Show **your error**, not the error in the other SO question. While a line "DSO missing from command line" exists both in your and other errors, other content of the errors differs (different functions, filenames, and so on). – Tsyvarev Sep 04 '18 at 11:03
  • hi Tsyvarev i just re-ran the command and added the exact error message. apologies for the delay. – Dale Baker Sep 05 '18 at 10:57
  • The "undefined reference" error you get is about missed linking to `pthread`. For proper using `pthread` in a CMake project, see that question: https://stackoverflow.com/questions/1620918/cmake-and-libpthread. How is `librealsense` is related with a problem? – Tsyvarev Sep 05 '18 at 11:38
  • I'd also like to know how to build the CMakeLists.txt file too. Unfortunately i dont know how to include the librealsense module without just putting it as a subdirectory and building it that way (which takes half an hour) so i was hoping someone could teach me how to find and add it as a package. – Dale Baker Sep 07 '18 at 10:32
  • Please, update your question post so it would reflect your **actual problem**. Currently, the question contains the error message, which could be resolved by reading the other SO question, and does NOT mention your intention to use librealsense as already existed library (without building it). – Tsyvarev Sep 07 '18 at 10:39

0 Answers0