Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erro in building #2

Open
hamedbagherii opened this issue Oct 26, 2023 · 3 comments
Open

Erro in building #2

hamedbagherii opened this issue Oct 26, 2023 · 3 comments

Comments

@hamedbagherii
Copy link

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

@peter-nebe
Copy link
Owner

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
Copy link
Owner

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

@hamedbagherii
Copy link
Author

hamedbagherii commented Nov 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants