I am on Ubuntu 20.04.1 LTS and currently I am working through the OpenSceneGraph 3.0 Tutorial by Rui Wang and Xuelei Qian and I am on page 87 trying to create the Teapot which requires the glut libraries and includes. After some research, I downloaded freeglut 3.2.1 and built it in my own directory. Needless to say I am a Ubuntu beginner and don't quite understand where something goes after the cmake make
command, let alone where something goes after the cmake install
command.
The following error comes up when trying to build:
/usr/bin/ld: CMakeFiles/MyProject.dir/main.cpp.o: in function `TeapotDrawable::drawImplementation(osg::RenderInfo&) const':
main.cpp:(.text+0x129): undefined reference to `glutSolidTeapot'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/MyProject.dir/build.make:91: MyProject] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/MyProject.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
So far I have used the following CMakeLists.txt file:
cmake_minimum_required(VERSION 2.6)
PROJECT(MyProject)
#find_package( GL )
find_package( OpenGL )
#find_package( freeglut REQUIRED ) // added REQUIRED
find_package( OpenThreads )
find_package( osg )
find_package( osgDB )
find_package( osgUtil )
find_package( osgViewer )
macro ( config_project PROJNAME LIBNAME )
include_directories( ${${LIBNAME}_INCLUDE_DIR} )
target_link_libraries( ${PROJNAME} ${${LIBNAME}_LIBRARY} )
endmacro()
add_executable( MyProject main.cpp )
config_project( MyProject OPENTHREADS )
config_project( MyProject OSG )
config_project( MyProject OSGDB )
config_project( MyProject OSGUTIL )
config_project( MyProject OSGVIEWER )
#config_project( MyProject FREEGLUT )
config_project( MyProject GLUT )
config_project( MyProject OPENGL )
The uncommented lines are me trying to get this to work.
This has worked for the other examples used in the book so far.
Freeglut, OSG and OpenGL are installed under the usr/local/include
dir
If any information is missing, I will of course edit this question accordingly. Thank you.
Edit: After adding the REQUIRED keyword, I get the following error from CMake:
CMake Error at CMakeLists.txt:7 (find_package):
By not providing "Findfreeglut.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "freeglut",
but CMake did not find one.
Could not find a package configuration file provided by "freeglut" with any
of the following names:
freeglutConfig.cmake
freeglut-config.cmake
Add the installation prefix of "freeglut" to CMAKE_PREFIX_PATH or set
"freeglut_DIR" to a directory containing one of the above files. If
"freeglut" provides a separate development package or SDK, be sure it has
been installed.