1

I am trying to run my first SFML application. I can run it via Code Blocks environment, but I can't run it through the Explorer - an error appears that says: "libgcc_s_sjlj-1.dll is missing". I added these lines to my linker options:

-static
-static-libgcc
-static-libstdc++

However, after trying to compile it, I see an error in the build log:

mingw32-g++.exe: error: unrecognized command line option '-static-libstdc++'

How can I fix it? My GCC version is 4.7.1 TDM-1

user3366592
  • 439
  • 7
  • 23

2 Answers2

1

GCC 4.7.1 is a rather old version, and the -static-libstdc++ is a rather new option. I believe it was there in the main GNU 4.7.x distribution, but there is some corroborating evidence that MinGW GCC 4.7.1 did not have it.

Anyhow, you shouldn't need to link the default libraries statically. Your TDM-GCC installation is the 32 bit variant. Assuming it resides in C:\TDM-GCC-32, then libgcc_s_sjlj-1.dll resides in C:\TDM-GCC-32\bin. Check that it is there. If not, your TDM-GCC installation is broken and you'll need to fix or reinstall it.

Otherwise, to run your program successfully at the Windows command prompt or from Explorer, C:\TDM-GCC-32\bin has to be in your PATH environment variable. Check if it is: (Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables -> PATH).

If it's present then I'm stumped. If not, append ;C:\TDM-GCC-32\bin to the PATH and OK out. Rebuild your program normally (without the -static-* options) and it will then run from Explorer, or from a new command prompt that you open (barring any other dynamic linkage problems).

You do not encounter this program when running the program from Code::Blocks because it automatically prefixes the PATH with the pathname to the binaries of the configured compiler before running your program.

Consider upgrading to the latest TDM GCC distribution.

Community
  • 1
  • 1
Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
0

(if you are using windows, specifically 7) You might want to check your path variable, search environment in your start menu's search bar, then click on "edit the system environment variables".

On the pop up click on environment variables go to the system variables section of the new popup, and look for path. click edit and copy the entire thing into a txt (it's long).

What you are looking at is a bunch of different paths that are searched first when trying to find dlls and such. You'll want to check if one of the paths is pointing to a compiler you no longer use. Then you'll want to check if your current compiler is mentioned.

If your compiler isn't mentioned, add it's bin folder to the variable and be sure to follow it with a semicolon. Make sure not to mess up any paths, and also save the path that you first copied down just in case. Copy all this back into the edit bar and submit it.

e.g. old path is

C:\Windows\System32

so add your compiler like this;

C:\Windows\System32;C:\mingw64\bin      // bin should contain g++ and such

Hopefully, your program now compiles. I had this problem a few weeks ago and this method worked for me. if it doesn't work change the path variable back to what it was, and I apologize.

user4578093
  • 231
  • 1
  • 3
  • 10
  • It's still not compiling :( – user3366592 Jun 27 '15 at 20:22
  • Another other option I know of is to find the relevant file (it would be in the bin folder of your compiler if it was anywhere on your computer) and copying it into your project folder then compiling with -static. You might be able to find the relevant file on the net, though I wouldn't recommend it. – user4578093 Jun 27 '15 at 21:43