stair-step-detector icon indicating copy to clipboard operation
stair-step-detector copied to clipboard

Erro in building

Open hamedbagherii opened this issue 2 years ago • 3 comments

Hi. I've tried to build the code. But I got this error. I wonder if you have any guidance on how can solve this issue. My Ubuntu version is 20.04. Thanks

Error:

[ 45%] Building CXX object CMakeFiles/detect-stairs.dir/stairs.cpp.o [ 50%] Building CXX object CMakeFiles/detect-stairs.dir/transformation.cpp.o [ 54%] Building CXX object CMakeFiles/detect-stairs.dir/window.cpp.o [ 59%] Linking CXX executable detect-stairs /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function device_with_streams(std::vector<rs2_stream, std::allocator<rs2_stream> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': geometricCalibration.cpp:(.text+0x4fe): multiple definition of device_with_streams(std::vector<rs2_stream, std::allocator<rs2_stream> >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x4fe): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function set_viewport(rect const&)': geometricCalibration.cpp:(.text+0xd86): multiple definition of set_viewport(rect const&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0xd86): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function draw_pointcloud(float, float, glfw_state&, rs2::points&)': geometricCalibration.cpp:(.text+0xe35): multiple definition of draw_pointcloud(float, float, glfw_state&, rs2::points&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0xe35): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function quat2mat(rs2_quaternion&, float*)': geometricCalibration.cpp:(.text+0x11dd): multiple definition of quat2mat(rs2_quaternion&, float*)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x11dd): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)': geometricCalibration.cpp:(.text+0x1538): multiple definition of draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1538): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function register_glfw_callbacks(window&, glfw_state&)': geometricCalibration.cpp:(.text+0x1ceb): multiple definition of register_glfw_callbacks(window&, glfw_state&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1ceb): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function get_screen_resolution(unsigned int&, unsigned int&)': geometricCalibration.cpp:(.text+0x1d9d): multiple definition of get_screen_resolution(unsigned int&, unsigned int&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1d9d): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function device_with_streams(std::vector<rs2_stream, std::allocator<rs2_stream> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': pointcloud.cpp:(.text+0x4fe): multiple definition of device_with_streams(std::vector<rs2_stream, std::allocator<rs2_stream> >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x4fe): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function set_viewport(rect const&)': pointcloud.cpp:(.text+0xd86): multiple definition of set_viewport(rect const&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0xd86): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function draw_pointcloud(float, float, glfw_state&, rs2::points&)': pointcloud.cpp:(.text+0xe35): multiple definition of draw_pointcloud(float, float, glfw_state&, rs2::points&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0xe35): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function quat2mat(rs2_quaternion&, float*)': pointcloud.cpp:(.text+0x11dd): multiple definition of quat2mat(rs2_quaternion&, float*)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x11dd): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)': pointcloud.cpp:(.text+0x1538): multiple definition of draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1538): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function register_glfw_callbacks(window&, glfw_state&)': pointcloud.cpp:(.text+0x1ceb): multiple definition of register_glfw_callbacks(window&, glfw_state&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1ceb): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function get_screen_resolution(unsigned int&, unsigned int&)': pointcloud.cpp:(.text+0x1d9d): multiple definition of get_screen_resolution(unsigned int&, unsigned int&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1d9d): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function device_with_streams(std::vector<rs2_stream, std::allocator<rs2_stream> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': window.cpp:(.text+0x4fe): multiple definition of device_with_streams(std::vector<rs2_stream, std::allocator<rs2_stream> >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x4fe): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function set_viewport(rect const&)': window.cpp:(.text+0xd86): multiple definition of set_viewport(rect const&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0xd86): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function draw_pointcloud(float, float, glfw_state&, rs2::points&)': window.cpp:(.text+0xe35): multiple definition of draw_pointcloud(float, float, glfw_state&, rs2::points&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0xe35): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function quat2mat(rs2_quaternion&, float*)': window.cpp:(.text+0x11dd): multiple definition of quat2mat(rs2_quaternion&, float*)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x11dd): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)': window.cpp:(.text+0x1538): multiple definition of draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1538): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function register_glfw_callbacks(window&, glfw_state&)': window.cpp:(.text+0x1ceb): multiple definition of register_glfw_callbacks(window&, glfw_state&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1ceb): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function get_screen_resolution(unsigned int&, unsigned int&)': window.cpp:(.text+0x1d9d): multiple definition of get_screen_resolution(unsigned int&, unsigned int&)'; CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o:detect-stairs.cpp:(.text+0x1d9d): first defined here /usr/bin/ld: CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o: in function draw_pointcloud(float, float, glfw_state&, rs2::points&)': detect-stairs.cpp:(.text+0xf00): undefined reference to gluPerspective' /usr/bin/ld: detect-stairs.cpp:(.text+0xf5e): undefined reference to gluLookAt' /usr/bin/ld: CMakeFiles/detect-stairs.dir/detect-stairs.cpp.o: in function draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)': detect-stairs.cpp:(.text+0x1630): undefined reference to gluPerspective' /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function draw_pointcloud(float, float, glfw_state&, rs2::points&)': geometricCalibration.cpp:(.text+0xf00): undefined reference to gluPerspective' /usr/bin/ld: geometricCalibration.cpp:(.text+0xf5e): undefined reference to gluLookAt' /usr/bin/ld: CMakeFiles/detect-stairs.dir/geometricCalibration.cpp.o: in function draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)': geometricCalibration.cpp:(.text+0x1630): undefined reference to gluPerspective' /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function draw_pointcloud(float, float, glfw_state&, rs2::points&)': pointcloud.cpp:(.text+0xf00): undefined reference to gluPerspective' /usr/bin/ld: pointcloud.cpp:(.text+0xf5e): undefined reference to gluLookAt' /usr/bin/ld: CMakeFiles/detect-stairs.dir/pointcloud.cpp.o: in function draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)': pointcloud.cpp:(.text+0x1630): undefined reference to gluPerspective' /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function draw_pointcloud(float, float, glfw_state&, rs2::points&)': window.cpp:(.text+0xf00): undefined reference to gluPerspective' /usr/bin/ld: window.cpp:(.text+0xf5e): undefined reference to gluLookAt' /usr/bin/ld: CMakeFiles/detect-stairs.dir/window.cpp.o: in function draw_pointcloud_wrt_world(float, float, glfw_state&, rs2::points&, rs2_pose&, float*, std::vector<rs2_vector, std::allocator<rs2_vector> >&)': window.cpp:(.text+0x1630): undefined reference to gluPerspective' collect2: error: ld returned 1 exit status gmake[2]: *** [CMakeFiles/detect-stairs.dir/build.make:273: detect-stairs] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/detect-stairs.dir/all] Error 2 gmake: *** [Makefile:91: all] Error 2

hamedbagherii avatar Oct 26 '23 18:10 hamedbagherii

Thanks for using the project. device_with_streams was introduced in RealSense v2.47. They define the function in the header file, but that is not correct. Unfortunately, you will have to adjust this or go back to an earlier version. I had only ever used v2.42.

peter-nebe avatar Oct 27 '23 07:10 peter-nebe

I'm sorry, I missed that I was fiddling with RealSense. In <librealsense-dir>/examples/example.hpp, change the set_viewport function to static, like so:

static void set_viewport(const rect& r)

And delete the following functions from the file:

draw_pointcloud
quat2mat
draw_pointcloud_wrt_world
register_glfw_callbacks

peter-nebe avatar Oct 29 '23 08:10 peter-nebe

Hi, I didn't change the RealSense version, but I made the following modifications:

I used the static void set_viewport(const rect& r) function (example.hpp). I removed the following functions from the code (example.hpp,):

draw_pointcloud quat2mat draw_pointcloud_wrt_world register_glfw_callbacks

As a result of these changes, I encountered fewer multiple definition errors. To resolve these errors, I removed the conflicting definitions from the code, and that solved the problem.

Thank you so much for your help.

hamedbagherii avatar Nov 03 '23 01:11 hamedbagherii