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

Author Topic: SFML Hello World project  (Read 572 times)

0 Members and 1 Guest are viewing this topic.

Nicolas Léonard

  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML Hello World project
« on: May 10, 2025, 01:41:36 am »
Sorry guys.  Total newbie to SFML here.

I am trying to test if I can use SFML for a personal project.  Well, I cannot even get a basic project to run.

Using Microsoft Visual Studio Community 2017    Version 15.9.21 (installed latest updates) for C++ under Windows 10 Pro.

Followed instructions from https://www.sfml-dev.org/tutorials/3.0/getting-started/visual-studio/ 
They seem pretty straightforward:
- downloaded the SFML 3.0.0 for VS 2017 Visual C++ 16 (2019) in both 32 and 64b
- created a new "Empty Project" in VS.
- set the C++ language to ISO C++ 17 Standard
- set the include path
- set the lib path
- added the following lib dependencies: sfml-graphics.lib, sfml-window.lib and sfml-system.lib (and the -d version for Debug configurations).
- copied the dlls to the executable folder.

I used exactly the suggested code (to draw a green circle) in a file named main.cpp added to the project.

First problem: the Release versions, in either Win32 or x64 platform, fail to compile causing a compiler crash.
1>------ Rebuild All started: Project: Project1, Configuration: Release x64 ------
1>main.cpp
1>c:\sfml\sfml-3.0.0-windows-vc16-64-bit\sfml-3.0.0\include\sfml\system\exception.hpp(42): warning C4275: non dll-interface class 'std::runtime_error' used as base for dll-interface class 'sf::Exception'

Ignoring this for now and moving on to running the Debug versions.  They compile and link but crash at runtime.

Exception thrown at 0x007818ED in Project1.exe: 0xC0000005: Access violation writing location 0x7C013190.
static inline const std::size_t InvalidPos{std::u32string::npos};      [file String.hpp l. 102]

Does anyone know where the problem could be, or if there is a ready-made SFML Hello World project file somewhere?
« Last Edit: May 10, 2025, 01:44:57 am by Nicolas Léonard »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11193
    • View Profile
    • development blog
    • Email
Re: SFML Hello World project
« Reply #1 on: May 11, 2025, 08:33:19 am »
First problem: the Release versions, in either Win32 or x64 platform, fail to compile causing a compiler crash.
1>------ Rebuild All started: Project: Project1, Configuration: Release x64 ------
1>main.cpp
1>c:\sfml\sfml-3.0.0-windows-vc16-64-bit\sfml-3.0.0\include\sfml\system\exception.hpp(42): warning C4275: non dll-interface class 'std::runtime_error' used as base for dll-interface class 'sf::Exception'
It doesn't fail to compile, it's just a warning. This has been fixed in SFML 3.0.1

Exception thrown at 0x007818ED in Project1.exe: 0xC0000005: Access violation writing location 0x7C013190.
static inline const std::size_t InvalidPos{std::u32string::npos};      [file String.hpp l. 102]

Does anyone know where the problem could be, or if there is a ready-made SFML Hello World project file somewhere?
This sounds like you didn't link the SFML libs with the -d suffix in debug mode. Make sure to double check for Win32 and x64.
Also note that you need different libraries for Win32 and x64
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/