SFML community forums
Help => General => Topic started by: stubbie on October 03, 2023, 05:50:39 pm
-
I am trying to compile a SFML project, but when i try to compile main.cpp it throws errors. The code I am using is exactly what is in the sfml-linux documentation. I am using endavouros if that may have a part in the issue. I have been able to run sfml projects up until today when I create a new project everything broke. I have also tried building from source, but no fix. It seems to be an issue with linking, however when I include all the libraries needed to compile my code I am still faced with errors. I followed the sfml-linux documentation to create the project and this is the error I am faced with when I try to build:
/usr/bin/ld: main.o: in function `main':
main.cpp:(.text+0xaf): undefined reference to `sf::VideoMode::VideoMode(sf::Vector2<unsigned int> const&, unsigned int)'
collect2: error: ld returned 1 exit status
Thank you to anyone who can help me.
-
Did you by any chance update SFML or the SFML headers?
The master branch is work in progress for SFML 3 and has some breaking changes
-
I have the sfml package installed from https://archlinux.org/packages/extra/x86_64/sfml/ , and have not touched any of the headers/code. It is left as is here https://www.sfml-dev.org/tutorials/2.6/start-linux.php . I read online that it is likely an issue with linking, but after installing from source the issue is still there.
-
This is almost certainly an issue with using SFML 3 headers alongside SFML 2 libraries. Try using the official template instead to avoid this problem.
https://github.com/SFML/cmake-sfml-project
-
I was able to fix it. The error was because when I tried to build from source, I was using the master branch which seems to be broken. I built from 2.6.x and was able to compile a project fine. I'm still not quite sure why i was not able to build projects with the packages installed from here: https://archlinux.org/packages/extra/x86_64/sfml/ , it seems some libraries from 3.0 are still installed somewhere, but atleast I was able to get something working.