How to get rid of GLU while using legacy OpenGL (1.x)

Issue

This Content is from Stack Overflow. Question asked by Prokop Hapala

When I compile my old program with CMake I keep getting this message:

-- WARNING: you are using the obsolete 'GLU' package, please use 'OpenGL' instead

OK, so I tried to remove this form CMakeFiles

find_package( OpenGL REQUIRED )
#find_package( GLU    REQUIRED )
find_package( SDL2   REQUIRED )

add_executable       ( test_app test_app.cpp $<TARGET_OBJECTS:SDL2OGL> $<TARGET_OBJECTS:DynamicOpt>  )
#target_link_libraries( test_app ${OpenGL_LIBRARY} ${GLU_LIBRARY} ${SDL2_LIBRARY} )
target_link_libraries( test_app ${OpenGL_LIBRARY} ${SDL2_LIBRARY} )

But then the legacy OpenGL functions are undefined?

undefined reference to `glTranslatef'
undefined reference to `glPopMatrix'
undefined reference to `glPushMatrix'
undefined reference to `glCallList'
undefined reference to `glColor3f'
undefined reference to `glDisable'
undefined reference to `glShadeModel'
...

So I don’t know, what should I do to link it against OpenGL properly. Do I need GLU for legacy OpenGL or not?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?