Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: OpenGl Tutorial Compile Issues  (Read 2890 times)

0 Members and 1 Guest are viewing this topic.

jthornton

  • Newbie
  • *
  • Posts: 1
    • View Profile
OpenGl Tutorial Compile Issues
« 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
Quote
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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: OpenGl Tutorial Compile Issues
« Reply #1 on: November 13, 2019, 10:02:33 am »
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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: OpenGl Tutorial Compile Issues
« Reply #2 on: November 13, 2019, 01:41:59 pm »
Quote
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
Laurent Gomila - SFML developer

 

anything