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

Author Topic: OpenGL errors when statically linking SFML 2.5.1  (Read 1800 times)

0 Members and 1 Guest are viewing this topic.

lightspot21

  • Newbie
  • *
  • Posts: 3
    • View Profile
OpenGL errors when statically linking SFML 2.5.1
« on: January 10, 2019, 03:49:06 pm »
Hello everyone,

I'm trying to link SFML statically for my project and when trying to compile I get errors that look like they're OpenGL's fault. The library is compiled from source (latest version of git repo's master branch)

What I'm talking about is this:

Scanning dependencies of target SFMLTest
[ 50%] Building CXX object CMakeFiles/SFMLTest.dir/main.cpp.o
[100%] Linking CXX executable SFMLTest
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::~GlxContext()':
GlxContext.cpp:(.text+0x2b): undefined reference to `glXGetCurrentContext'
GlxContext.cpp:(.text+0x3d): undefined reference to `glXDestroyContext'
GlxContext.cpp:(.text+0x71): undefined reference to `glXDestroyPbuffer'
GlxContext.cpp:(.text+0xa9): undefined reference to `glXMakeCurrent'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::makeCurrent(bool)':
GlxContext.cpp:(.text+0x129): undefined reference to `glXMakeCurrent'
GlxContext.cpp:(.text+0x150): undefined reference to `glXMakeContextCurrent'
GlxContext.cpp:(.text+0x168): undefined reference to `glXMakeCurrent'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::~GlxContext()':
GlxContext.cpp:(.text+0x19b): undefined reference to `glXGetCurrentContext'
GlxContext.cpp:(.text+0x1ad): undefined reference to `glXDestroyContext'
GlxContext.cpp:(.text+0x1f1): undefined reference to `glXDestroyPbuffer'
GlxContext.cpp:(.text+0x221): undefined reference to `glXMakeCurrent'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::selectBestVisual(_XDisplay*, unsigned int, sf::ContextSettings const&)':
GlxContext.cpp:(.text+0x537): undefined reference to `glXGetConfig'
GlxContext.cpp:(.text+0x55b): undefined reference to `glXGetConfig'
GlxContext.cpp:(.text+0x570): undefined reference to `glXGetConfig'
GlxContext.cpp:(.text+0x585): undefined reference to `glXGetConfig'
GlxContext.cpp:(.text+0x59d): undefined reference to `glXGetConfig'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o):GlxContext.cpp:(.text+0x5b5): more undefined references to `glXGetConfig' follow
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::createSurface(sf::priv::GlxContext*, unsigned int, unsigned int, unsigned int)':
GlxContext.cpp:(.text+0xc8b): undefined reference to `glXQueryVersion'
GlxContext.cpp:(.text+0xcba): undefined reference to `glXChooseFBConfig'
GlxContext.cpp:(.text+0xce0): undefined reference to `glXGetVisualFromFBConfig'
GlxContext.cpp:(.text+0xd6a): undefined reference to `glXCreatePbuffer'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::createContext(sf::priv::GlxContext*)':
GlxContext.cpp:(.text+0xf50): undefined reference to `glXQueryDrawable'
GlxContext.cpp:(.text+0xf97): undefined reference to `glXChooseFBConfig'
GlxContext.cpp:(.text+0x1071): undefined reference to `glXQueryVersion'
GlxContext.cpp:(.text+0x115c): undefined reference to `glXChooseFBConfig'
GlxContext.cpp:(.text+0x1180): undefined reference to `glXGetVisualFromFBConfig'
GlxContext.cpp:(.text+0x1290): undefined reference to `glXGetVisualFromFBConfig'
GlxContext.cpp:(.text+0x12fb): undefined reference to `glXMakeCurrent'
GlxContext.cpp:(.text+0x1318): undefined reference to `glXCreateContext'
GlxContext.cpp:(.text+0x1685): undefined reference to `glXMakeCurrent'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::GlxContext(sf::priv::GlxContext*)':
GlxContext.cpp:(.text+0x1a93): undefined reference to `glXQueryVersion'
GlxContext.cpp:(.text+0x1acb): undefined reference to `glXChooseFBConfig'
GlxContext.cpp:(.text+0x1aff): undefined reference to `glXGetVisualFromFBConfig'
GlxContext.cpp:(.text+0x1b74): undefined reference to `glXCreatePbuffer'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::GlxContext(sf::priv::GlxContext*, sf::ContextSettings const&, unsigned int, unsigned int)':
GlxContext.cpp:(.text+0x1f8b): undefined reference to `glXQueryVersion'
GlxContext.cpp:(.text+0x1fc3): undefined reference to `glXChooseFBConfig'
GlxContext.cpp:(.text+0x1ff1): undefined reference to `glXGetVisualFromFBConfig'
GlxContext.cpp:(.text+0x206d): undefined reference to `glXCreatePbuffer'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::display()':
GlxContext.cpp:(.text+0xdd): undefined reference to `glXSwapBuffers'
/usr/local/lib/libsfml-window-s.a(GlxContext.cpp.o): In function `sf::priv::GlxContext::getFunction(char const*)':
GlxContext.cpp:(.text+0x3f1): undefined reference to `glXGetProcAddressARB'
/usr/local/lib/libsfml-window-s.a(GlxExtensions.cpp.o): In function `sfglx_LoadFunctions':
GlxExtensions.cpp:(.text+0x1d8): undefined reference to `glXQueryExtensionsString'
collect2: error: ld returned 1 exit status
CMakeFiles/SFMLTest.dir/build.make:101: recipe for target 'SFMLTest' failed
make[3]: *** [SFMLTest] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/SFMLTest.dir/all' failed
make[2]: *** [CMakeFiles/SFMLTest.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/SFMLTest.dir/rule' failed
make[1]: *** [CMakeFiles/SFMLTest.dir/rule] Error 2
Makefile:118: recipe for target 'SFMLTest' failed
make: *** [SFMLTest] Error 2


I'm trying to compile the first sample script from "SFML and Linux" tutorial at the Learn section of the site. It works correctly when linking dynamically.

My CMakeLists.txt if anyone's interested:

cmake_minimum_required(VERSION 3.13)
project(SFMLTest)

set(CMAKE_CXX_STANDARD 11)
set(SFML_STATIC_LIBRARIES true)

find_package(SFML REQUIRED window audio graphics system network)

set(SFML_LINKS sfml-audio sfml-window sfml-graphics sfml-system sfml-network)

add_executable(SFMLTest main.cpp)
target_link_libraries(SFMLTest ${SFML_LINKS})


Thanks in advance.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: OpenGL errors when statically linking SFML 2.5.1
« Reply #1 on: January 10, 2019, 04:01:53 pm »
When linking statically, you must also link all the SFML dependencies to your executable. We have a list of such dependencies in tutorials for Windows environments, but not for Linux as it is quite uncommon to use static libraries.
Laurent Gomila - SFML developer

 

anything