SFML community forums
Help => General => Topic started by: jthornton on November 12, 2019, 12:29:41 am
-
I'm following https://www.sfml-dev.org/tutorials/2.5/window-opengl.php for opengl and I fail to compile it.
Debian 10
sfml installed via apt install libsfml-dev
g++ -c main.cpp
g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
john@d10cave:~/github/dxf2plasma/cpp/openGl$ g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
/usr/bin/ld: main.o: undefined reference to symbol 'glViewport'
/usr/bin/ld: //lib/x86_64-linux-gnu/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
From the tutorial
You will then need to link your program to the OpenGL library. Unlike what it does with the headers, SFML can't provide a unified way of linking OpenGL. Therefore, you need to know which library to link to according to what operating system you're using ("opengl32" on Windows, "GL" on Linux, etc.).
How does one "know" what OpenGl library they have?
JT
-
As mentioned it's most likely just gl that you need to link, but since Linux is such a diverse ecosystem, it's impossible to define specific library names and it's assumed that people using their flavor of Linux distro will know what needs to be used.
-
How does one "know" what OpenGl library they have?
One reads linker output more carefully ;)
libGL.so.1: error adding symbols: DSO missing from command line
-> libGL.so.1, so it's -lGL on the command line