I’m trying to build the OpenGL Super Bible 7th edition code samples on Ubuntu 16.04. First I have to run cmake, which seems to work, and then I have to run make to compile.
I believe I have installed glfw3 and the Mesa OpenGL packages. When I execute cmake (after installing libglfw3 and libglfw3-dev), I get messages that OpenGL and GLFW3 have been found:
-- Found OpenGL: /usr/lib/libGL.so
-- Checking for module 'glfw3'
-- Found glfw3, version 3.1.2
But when I execute make after cmake finishes, I get this error:
/sb7code-master/src/sb7/sb7object.cpp: In member function ‘void sb7::object::render_sub_object(unsigned int, unsigned int, unsigned int)’:
/sb7code-master/src/sb7/sb7object.cpp:212:77: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
(void*)sub_object[object_index].first,
^
[ 3%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7shader.cpp.o
[ 4%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7textoverlay.cpp.o
[ 4%] Building C object CMakeFiles/sb7.dir/src/sb7/gl3w.c.o
[ 5%] Linking CXX static library lib/libsb7.a
[ 5%] Built target sb7
Scanning dependencies of target wrapmodes
[ 6%] Building CXX object CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o
[ 7%] Linking CXX executable ../bin/wrapmodes
/usr/bin/ld: cannot find -lglfw3
collect2: error: ld returned 1 exit status
CMakeFiles/wrapmodes.dir/build.make:95: recipe for target '../bin/wrapmodes' failed
make[2]: *** [../bin/wrapmodes] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/wrapmodes.dir/all' failed
make[1]: *** [CMakeFiles/wrapmodes.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
So I tried to see whether glfw3 was installed. I am a Linux newbie, so I found these commands online:
sudo pkg-config --libs glfw3
That spits out:
-lglfw
Whereas when I enter sudo pkg-config --libs glfw
without a 3 on the end I get:
Package glfw was not found in the pkg-config search path.
Perhaps you should add the directory containing `glfw.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glfw' found
And I tried: sudo ldconfig -p | grep "glfw"
That spits out:
libglfw.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libglfw.so.3
In contrast, sudo ldconfig -p | grep "glfw3"
returns nothing.
Is this cmake file I downloaded set up incorrectly to tell the linker -lglfw3
, when it should be telling it -lglfw
? Or are my library paths somehow not correctly defined?
Advertisement
Answer
Bad/out-of-date CMakeLists.txt
.
set(COMMON_LIBS sb7 glfw3 X11 Xrandr Xinerama Xi Xxf86vm Xcursor GL rt dl)
^ wat
Should be:
set(COMMON_LIBS sb7 glfw X11 Xrandr Xinerama Xi Xxf86vm Xcursor GL rt dl)
^ no 3
Better yet they should probably be using find_package()
to find GLFW.