ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Need advice on including OpenGL/GLUT in makefile

asked 2015-03-11 11:51:19 -0500

rnunziata gravatar image

updated 2015-03-11 13:17:39 -0500

update: I added OpenCV but still same error.

in my package.xml i have

 <build_depend>OpenGL</build_depend>

in my Cmakefile i have

include_directories(include 
                    ${catkin_INCLUDE_DIRS}
                    ${OpenGL_INCLUDE_DIRS}
                    ${TinyXML_INCLUDE_DIRS}

target_link_libraries(ar_track_alvar ${OpenGL_LIBRARIES)  ${TinyXML_LIBRARIES} ${catkin_LIBRARIES})

but i get the error:

make[1]: *** [ar_track_alvar/ar_track_alvar/CMakeFiles/individualMarkersNoKinect.dir/all] Error 2
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutInitDisplayMode'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutDisplayFunc'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutSpecialFunc'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutMouseFunc'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutPostRedisplay'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutCreateWindow'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `alvar::CameraEC::UpdatePose(CvMat const*, CvMat*, alvar::Pose*, CvMat*)'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutSetWindow'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `alvar::CameraEC::Get3dOnPlane(alvar::Pose const*, CvPoint2D32f, CvPoint3D32f&)'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutSwapBuffers'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutMainLoop'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutPositionWindow'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutInit'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutInitWindowSize'
/home/richard/catkin_ws/devel/lib/libar_track_alvar.so: undefined reference to `glutMotionFunc'
collect2: error: ld returned 1 exit status
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2015-03-12 02:20:00 -0500

gvdhoorn gravatar image

updated 2015-03-12 08:52:03 -0500

While your own approach works, I wouldn't recommend it, as you are hardcoding the name of the GLUT library and making assumptions about its presence on your system.

You only included a few lines of your CMakeLists.txt, so you could already be doing this, but just as an example (only showing relevant parts):

find_package(catkin REQUIRED ..)

find_package(GLUT REQUIRED)
find_package(OpenGL REQUIRED)

..

# setup include path for both OpenGL & GLUT (and other dependencies)
include_directories(
  include 
  ${catkin_INCLUDE_DIRS}
  ${OpenGL_INCLUDE_DIRS}
  ${GLUT_INCLUDE_DIRS}
  ..
)

..

# now link target against all required libs
target_link_libraries(
  ar_track_alvar
    ${OPENGL_LIBRARIES}
    ${GLUT_LIBRARY}
    ..
    ${catkin_LIBRARIES}
)

Then also add a build_depend on glut (which is the rosdep key for Glut according to rosindex/d/glut).

Finally, be sure to add both OpenGL and GLUT (and any other system dependencies that you are using) to the DEPENDS argument of catkin_package(..).

in my package.xml i have

<build_depend>OpenGL</build_depend>

According to rosindex/d/opengl, the rosdep key is actually opengl (all lowercase).


Edit:

opengl lower case only shows in QT library while OpenGL shows in /usr/lib/python2.7/dist-packages/OpenGL

rosdep keys do not have to correspond in any way to any 'real' library, file, directory or package. They are simply a key into a database that maps to platform specific pkgs.

The rosdep key for all packages that provide OpenGL dev hdrs/libs on all supported platforms is really opengl (see rosdep/base.yaml, lines 2522 to 2531).

edit flag offensive delete link more

Comments

opengl lower case only shows in QT library while OpenGL shows in /usr/lib/python2.7/dist-packages/OpenGL

rnunziata gravatar image rnunziata  ( 2015-03-12 08:30:49 -0500 )edit
0

answered 2015-03-11 13:42:29 -0500

rnunziata gravatar image

changing the target link line adding -lglut fixed these issues

target_link_libraries(ar_track_alvar ${OpenGL_LIBS} ${OpenCV_LIBRS} ${TinyXML_LIBRARIES} ${catkin_LIBRARIES} -lglut)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-11 11:51:19 -0500

Seen: 7,906 times

Last updated: Mar 12 '15