SFML community forums

Help => General => Topic started by: Me-Myself-And-I on August 07, 2023, 08:08:44 pm

Title: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: Me-Myself-And-I on August 07, 2023, 08:08:44 pm
I can't get a program to run from executable when it uses sfml.It doesn't run without being in the IDE.Running the program from exe gives this kind of error.
---------------------------
Project2.exe - System Error
---------------------------
The program can't start because libgcc_s_sjlj-1.dll is missing from your computer. Try reinstalling the program to fix this problem.
---------------------------
OK   
---------------------------

I find that adding the missing file does bypass this particular error but then something else related to gcc is missing.
I'm using Devc++ 5.11,SFML 2.4.2,and GCC 4.9.2.

My directory settings are:
C:\SFML-2.4.2\lib //for libraries
C:\SFML-2.4.2\include //for includes
//both are accurate.

My Linker settings are:
-lsfml-audio
-lsfml-graphics
-lsfml-system
-lsfml-window

I'm using windows 7 but I have also tried this with the same properties on windows 10 too.
Does anyone see what's wrong here? I could sure use a clue.
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: eXpl0it3r on August 10, 2023, 11:03:08 am
Yes, there are multiple DLLs from GCC/MinGW you need to copy from the MinGW bin/ directory to get it working.
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: Me-Myself-And-I on August 15, 2023, 05:12:42 am
That works fine!  ;D
Theres just one thing.
How do I statically link these dll's?I never had to copy the dll's when I used mingw without an IDE.
btw I tried adding -static -static-libgcc -static-libstdc++ to the linker.
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: eXpl0it3r on August 15, 2023, 07:50:04 am
You'll have to also statically link SFML to use a static runtime library.

See the Code::Blocks tutorial for the basics with MinGW: https://www.sfml-dev.org/tutorials/2.6/start-cb.php
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: Me-Myself-And-I on August 15, 2023, 04:05:46 pm
I see now.All this time I thought sfml was statically linked when it wasn't. :P
Are all the dependencies in the sfml folder or do I have to download them?
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: eXpl0it3r on August 15, 2023, 04:44:56 pm
On Windows, all the non-system dependencies are shipped with SFML, yes.

System dependencies like OpenGL, winmm or winsock are provided by your system/compiler, so you don't need to know exactly where they are located, as your linker will automatically know.
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: Me-Myself-And-I on August 15, 2023, 05:27:01 pm
Is this right?
-static -static-libgcc -static-libstdc++  -lopengl32 -lfreetype -lwinmm -lgdi32 -lflac -lvorbisenc -lvorbisfile -lvorbis -logg -lws2_32    -lsfml-system-s -lsfml-network-s -lsfml-window-s -lsfml-graphics-s  -lsfml-audio-s

Where do I define SFML_STATIC? I tried defining it at the beginning of my main.cpp file but I get undefined reference errors.
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: eXpl0it3r on August 15, 2023, 05:48:21 pm
Ah, ehm something I hadn't mentioned, if you want to use static runtime libs, you'll also have to rebuild SFML with it. ;D

Where do I define SFML_STATIC? I tried defining it at the beginning of my main.cpp file but I get undefined reference errors.
You define it on the compile command -DSFML_STATIC.

Personally, I highly recommend using CMake instead of makefiles or even worse, hand built commands.
The CMake template (https://github.com/SFML/cmake-sfml-project) also makes it really easy, as it builds SFML from source for you, so it's 100% compatible.
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: Me-Myself-And-I on August 15, 2023, 07:15:24 pm
Thankyou for all the help you've given.
Ok.I got the source of sfml.
I linked the dependencies.
-static -static-libgcc -static-libstdc++  -lopengl32-lopenal32-lfreetype-lwinmm-lgdi32-lflac-lvorbisenc-lvorbisfile-lvorbis-logg-lws2_32-lsfml-graphics-s-lsfml-window-s-lsfml-system-s-lsfml-audio-s-lsfml-network-s
I'm using devc++ 5.11
under binaries I added C:\SFML-2.4.2\extlibs\bin\x86
under libraries I added C:\SFML-2.4.2\extlibs\libs-mingw\x86
under c++ include I added C:\SFML-2.4.2\include
I added SFML_STATIC to the window that adds commands when calling the compiler.
I get the following errors:
cannot find -lfreetype
cannot find -lflac
cannot find -lvorbisenc
cannot find -lvorbisfile
cannot find -lvorbis
cannot find -logg
cannot find -lsfml-system-s
cannot find -lsfml-network-s
cannot find -lsfml-window-s
cannot find -lsfml-graphics-s
cannot find -lsfml-audio-s


Any ideas what i'm doing wrong?


Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: eXpl0it3r on August 15, 2023, 07:58:46 pm
You don't need C:\SFML-2.4.2\extlibs\bin\x86, but you do need to add C:\SFML-2.4.2\lib
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: Me-Myself-And-I on August 15, 2023, 10:32:42 pm
That's what I thought but the sfml lib folder is missing. ???
 Directory of C:\SFML-2.4.2

08/15/2023  12:49 PM    <DIR>          .
08/15/2023  12:49 PM    <DIR>          ..
08/15/2023  12:48 PM               521 .editorconfig
08/15/2023  12:48 PM            20,817 changelog.txt
08/15/2023  12:49 PM    <DIR>          cmake
08/15/2023  12:48 PM            16,534 CMakeLists.txt
08/15/2023  12:48 PM               727 CONTRIBUTING
08/15/2023  12:49 PM    <DIR>          doc
08/15/2023  12:49 PM    <DIR>          examples
08/15/2023  12:49 PM    <DIR>          extlibs
08/15/2023  12:49 PM    <DIR>          include
08/15/2023  12:48 PM             1,258 license.txt
08/15/2023  12:48 PM             1,779 readme.txt
08/15/2023  12:49 PM    <DIR>          src
08/15/2023  12:49 PM    <DIR>          tools
               6 File(s)         41,636 bytes
               9 Dir(s)  56,999,878,656 bytes free
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: eXpl0it3r on August 18, 2023, 11:30:21 pm
If you just download the source code, you first have to build the library itself. See also the Compiling with CMake tutorial: https://www.sfml-dev.org/tutorials/2.6/compile-with-cmake.php
Tbh at this point, you'd be better of with the SFML CMake Template: https://github.com/SFML/cmake-sfml-project

Download the pre-built binaries, if you don't want to build the library.
Title: Re: sfml compiles in IDE but is missing gcc files when run from executable.
Post by: Me-Myself-And-I on August 20, 2023, 12:05:03 am
I decided to be satisfied with just copying the dlls.Thanks anyway.