SFML community forums

Help => General => Topic started by: Grundkurs on October 17, 2021, 07:38:24 pm

Title: Can't compile SFML on Windows 11
Post by: Grundkurs on October 17, 2021, 07:38:24 pm
[EDIT]
I could pinpoint the issue: https://winlibs.com/ offers two versions of the mingw-w64 compiler: One ships with UCRT runtime, the other with MSVCRT runtime. With MSVCRT runtime i had no compilation issues. Visual Studio Compiler also had no issues compiling SFML on Windows 11. So i guess its something with the UCRT runtime.
[/EDIT]


I tried to compile SFML on Windows 11 and it fails with the following error-message:

[ 79%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTextureImpl.cpp.obj
[ 79%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTextureImplFBO.cpp.obj
[ 80%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTextureImplDefault.cpp.obj
[ 81%] Building RC object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/sfml-graphics.rc.obj
[ 82%] Linking CXX shared library ..\..\..\lib\sfml-graphics-2.dll
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Keen/Downloads/SFML-master/extlibs/libs-mingw/x64/libfreetype.a(sfnt.c.obj):sfnt.c:(.text+0x5614): undefined reference to `_setjmp'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Keen/Downloads/SFML-master/extlibs/libs-mingw/x64/libfreetype.a(smooth.c.obj):smooth.c:(.text+0x77a): undefined reference to `_setjmp'

collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [src\SFML\Graphics\CMakeFiles\sfml-graphics.dir\build.make:602: lib/sfml-graphics-2.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:307: src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/all] Error 2
mingw32-make: *** [makefile:155: all] Error 2


I did not have this issue on Windows 10 using the same procedure described below:


It compiles until 82 % and than cannot find '_setjmp'.
Compilation of SFML always worked for me in the past, this is the first time that it cannot get through to 100 %. Maybe it has something to do with Win 11?
Title: Re: Can't compile SFML on Windows 11
Post by: eXpl0it3r on October 18, 2021, 10:13:30 am
There's always a chance that with new OS versions that some libraries need fixes or rebuilds.
As the fix for Ryzen CPU issue (https://www.pcgamer.com/windows-11-insider-patch-fixes-major-amd-ryzen-bug/) are currently only on Insider builds, I'll wait some more weeks for the final release, before updating to Windows 11, then I can take a look.
Title: Re: Can't compile SFML on Windows 11
Post by: Powereleven on November 07, 2021, 08:23:02 am
I'm on Windows 10 and get the same error
Title: Re: Can't compile SFML on Windows 11
Post by: azkalaak on March 05, 2022, 10:56:57 am
I had the same problem (windows 11 using conan to build dependencies and sfml)

However, my problem was due to a mismatch in my conan build, the libfreetype building using g++ and the SFML building using clang++

after purging the sources and using the same compiler and linker to build each dependencies I had no more problems, it does not seem to be a SFML related issue
(it happened when I tried using the sf::Font class)
Title: Re: Can't compile SFML on Windows 11
Post by: eXpl0it3r on March 05, 2022, 12:52:52 pm
See edit at the top. It's caused by using different runtime libs. SFML's dependencies were compiled with MSVCRT, thus you can mix it with a compiler using UCRT
Title: Re: Can't compile SFML on Windows 11
Post by: darkonaito_ on August 07, 2022, 03:21:44 am
Is the problem with UCRT ever going to be fixed? I'm having it on windows 10
Title: Re: Can't compile SFML on Windows 11
Post by: eXpl0it3r on August 08, 2022, 05:11:49 pm
It's not really something to "fix", because it's simply two different runtime libraries, which SFML then also would have to compile for and distribute. Currently there are no plans to do so, if you want to use UCRT, you'll need to rebuild SFML's dependencies yourself.

In the near-ish future, SFML will stop providing the dependencies as binaries and instead always build from source.
Title: Re: Can't compile SFML on Windows 11
Post by: darkonaito_ on October 30, 2022, 12:24:51 am
I was using the term "fix" because, as far as I read, MSVCR is a bit stuck in the past. How hard is it to build the dependencies? Do you think it's worth?
Title: Re: Can't compile SFML on Windows 11
Post by: eXpl0it3r on October 30, 2022, 01:52:42 am
Not really, given that you can just download the other compiler version and everything starts working fine :D