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

Author Topic: Building SFML project error with sf::VideoMode  (Read 1453 times)

0 Members and 1 Guest are viewing this topic.

stubbie

  • Newbie
  • *
  • Posts: 5
    • View Profile
Building SFML project error with sf::VideoMode
« 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.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Building SFML project error with sf::VideoMode
« Reply #1 on: October 03, 2023, 09:03:31 pm »
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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

stubbie

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Building SFML project error with sf::VideoMode
« Reply #2 on: October 03, 2023, 11:22:00 pm »
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.

Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 57
    • View Profile
Re: Building SFML project error with sf::VideoMode
« Reply #3 on: October 04, 2023, 03:38:34 am »
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

stubbie

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Building SFML project error with sf::VideoMode
« Reply #4 on: October 04, 2023, 05:24:11 pm »
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.

 

anything