SFML community forums

Help => General => Topic started by: Me-Myself-And-I on August 26, 2024, 07:37:00 pm

Title: Trouble building SFML from source.
Post by: Me-Myself-And-I on August 26, 2024, 07:37:00 pm
Hello. I tried building SFML from source and ran into some errors. After generating the mingw makefile using cmake I tried building the library using "mingw32-make install".

[  0%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.obj
C__~1.EXE: error: unrecognized command line option '-Wnull-dereference'
C__~1.EXE: error: unrecognized command line option '-Wmisleading-indentation'
C__~1.EXE: error: unrecognized command line option '-Wduplicated-cond'

Help would be greatly appreciated. :)
Title: Re: Trouble building SFML from source.
Post by: eXpl0it3r on August 26, 2024, 11:48:13 pm
Are you using a very old compiler?

The SFML master branch (SFML 3 WIP) requires a C++17 compatible compiler.

If you want to stick to MinGW, I recommend WinLibs (https://winlibs.com/)
Title: Re: Trouble building SFML from source.
Post by: Me-Myself-And-I on August 27, 2024, 01:51:01 am
Yes,I was using a old compiler. I'll try using that then.
Title: Re: Trouble building SFML from source.
Post by: Me-Myself-And-I on August 27, 2024, 02:02:23 am
I used the compiler you showed and made sure the bin folder was in the environment variables but it still gives the exact same error.

[  0%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.obj
C__~1.EXE: error: unrecognized command line option '-Wnull-dereference'
C__~1.EXE: error: unrecognized command line option '-Wmisleading-indentation'
C__~1.EXE: error: unrecognized command line option '-Wduplicated-cond'
mingw32-make[2]: *** [src\SFML\System\CMakeFiles\sfml-system.dir\build.make:76: src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:202: src/SFML/System/CMakeFiles/sfml-system.dir/all] Error 2
mingw32-make: *** [makefile:155: all] Error 2


EDIT:

Nevermind. That fixed it after I set cmake to use that compiler instead of the other.  Thanks a lot! :D
Title: Re: Trouble building SFML from source.
Post by: Me-Myself-And-I on August 27, 2024, 02:28:03 am
Well now I'm having another problem. ???

[100%] Linking CXX shared library ..\..\..\lib\sfml-audio-2.dll
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:/Users/Humor/Downloads/SFML-2.6.1-sources/SFML-2.6.1/extlibs/libs-mingw/x86/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0xfd): undefined reference to `_imp___iob'
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:/Users/Humor/Downloads/SFML-2.6.1-sources/SFML-2.6.1/extlibs/libs-mingw/x86/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x144): undefined reference to `_imp___iob'
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:/Users/Humor/Downloads/SFML-2.6.1-sources/SFML-2.6.1/extlibs/libs-mingw/x86/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x184): undefined reference to `_imp___iob'
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:/Users/Humor/Downloads/SFML-2.6.1-sources/SFML-2.6.1/extlibs/libs-mingw/x86/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x400): undefined reference to `_imp___iob'
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:/Users/Humor/Downloads/SFML-2.6.1-sources/SFML-2.6.1/extlibs/libs-mingw/x86/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x4db1): undefined reference to `_imp___iob'
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:/Users/Humor/Downloads/SFML-2.6.1-sources/SFML-2.6.1/extlibs/libs-mingw/x86/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x5064): more undefined references to `_imp___iob' follow
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [src\SFML\Audio\CMakeFiles\sfml-audio.dir\build.make:453: lib/sfml-audio-2.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:333: src/SFML/Audio/CMakeFiles/sfml-audio.dir/all] Error 2
mingw32-make: *** [makefile:155: all] Error 2
Title: Re: Trouble building SFML from source.
Post by: eXpl0it3r on August 27, 2024, 10:53:15 pm
Oh, I thought you were building master. If you're building 2.6.1, you'll need a non-UCRT MinGW compiler.

Or you could build the 2.6.x branch, which contains some fixes, including support for UCRT MinGW compilers.
Title: Re: Trouble building SFML from source.
Post by: Me-Myself-And-I on August 28, 2024, 12:23:45 am
I don't understand. Shouldn't the latest SFML be able to be compiled from source using the latest GCC compiler? I am using GCC 14.2.0 and SFML 2.6.1.

EDIT:

Nevermind. I got the latest SFML binary to work with GCC 13 instead. I'm just gonna give up on building SFML from source. Thanks for the help anyways. :)
Title: Re: Trouble building SFML from source.
Post by: eXpl0it3r on August 28, 2024, 08:20:46 am
It does, if you use a MSVCRT-based compiler instead of an UCRT one, or if you rebuild SFML's dependencies with your URCT-based compiler, which is what we did on the 2.6.x branch.
Title: Re: Trouble building SFML from source.
Post by: svet-am on September 06, 2024, 04:44:13 am
@eXpl0it3r - I am just getting in to SFML development (and desktop application development in general -- I'm an embedded systems guy by trade).

I'm running in to issues (namely the infamous _setjmp linker failure with libfreetype) with my UCRT compiler toolchain (which I would prefer to use) and the in-built SFML dependencies.  When you say "recompile the dependencies from source", I've been trying to figure out how to do exactly that but can't quite get it.  Is that process covered in the tutorials?  If so, I've not seen it and would appreciate the pointer to the information so I can read it.
Title: Re: Trouble building SFML from source.
Post by: eXpl0it3r on September 06, 2024, 08:07:34 am
We have added newly built dependencies using UCRT to the SFML 2.6.x branch.
If you use the SFML CMake Template (https://github.com/SFML/cmake-sfml-project), you'll automatically fetch the latest changes from that branch and build it with your solution.

As such, you no longer have to rebuild SFML's dependencies.
And this isn't covered in any tutorial, but there's a repo (https://github.com/eXpl0it3r/SFML-dependencies) that has some tooling around building the dependencies.
For SFML 3, we plan to fetch all the dependencies source code (https://github.com/SFML/SFML/pull/3141) and always build them from scratch, instead of shipping binaries in the repo.