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

Author Topic: sfml compiles in IDE but is missing gcc files when run from executable.  (Read 1184 times)

0 Members and 1 Guest are viewing this topic.

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #2 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.
« Last Edit: August 15, 2023, 05:19:51 am by Me-Myself-And-I »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #3 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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #4 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?
« Last Edit: August 15, 2023, 04:13:48 pm by Me-Myself-And-I »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #5 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #6 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.
« Last Edit: August 15, 2023, 05:31:01 pm by Me-Myself-And-I »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #7 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 also makes it really easy, as it builds SFML from source for you, so it's 100% compatible.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #8 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?


« Last Edit: August 15, 2023, 07:19:15 pm by Me-Myself-And-I »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #9 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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #10 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #11 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: sfml compiles in IDE but is missing gcc files when run from executable.
« Reply #12 on: August 20, 2023, 12:05:03 am »
I decided to be satisfied with just copying the dlls.Thanks anyway.