Code::Blocks Forums

User forums => Help => Topic started by: Gnomoron on May 05, 2020, 10:14:10 am

Title: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: Gnomoron on May 05, 2020, 10:14:10 am
Hello everyone!

I use nighty build (12072) (http://forums.codeblocks.org/index.php/topic,23852.0.html) of Code::Blocks (OS Windows 10 Home). I installed MinGW-w64 (for building 64-bit apps) and MinGW-32 (for 32-bit apps) and configured Code::Blocks for working with them. I have problems starting 32-bit applications after they are compiled. If I start the application from IDE, then the application starts normally, but if I start it manually from the explorer, it warns that the libgcc_s_dw2-1.dll is missing. I tried to turn on in the global compiler settings and project build options flags -static, -static-libgcc and -static-libstdc++, but they didn't work. Please, help me. I don't know what's wrong. Thank you in advance.

P.S.: Sorry for bad English.
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: Miguel Gimenez on May 05, 2020, 11:22:00 am
Post a full rebuild log, http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F)
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: Gnomoron on May 05, 2020, 11:45:30 am
Code
-------------- Build: win32-d in Game (compiler: mingw-32)---------------

mingw32-g++.exe -Wall -std=c++17 -fexceptions -m32 -Og -g -m32 -Ilibraries\SFML-2.5.1\include -c D:\C++\Project\main.cpp -o obj\w32\debug\main.o
mingw32-g++.exe -Llibraries\SFML-2.5.1\lib -o bin\app32-debug.exe obj\w32\debug\main.o  -static-libstdc++ -static-libgcc -m32  -lsfml-network -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system -mwindows
Output file is bin\w32\app32-debug.exe with size 1.93 MB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: Miguel Gimenez on May 05, 2020, 12:00:49 pm
Probably some of the sfml libraries use exceptions, and this can prevent the static linking of libgcc. If this is the case, just copy the dll from the MinGW folder to the folder containing your executable.
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: Gnomoron on May 05, 2020, 12:08:38 pm
But when compiling a 64-bit application using mingw-w64 from the same sources using sfml, such an error does not occur. Perhaps I did something wrong when setting up the compiler?
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: Miguel Gimenez on May 05, 2020, 12:37:23 pm
Compare the buid logs; in the one you posted the -static flag is missing.
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: Gnomoron on May 05, 2020, 02:56:25 pm
-static didn't help :c
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: stahta01 on May 05, 2020, 04:48:09 pm
But when compiling a 64-bit application using mingw-w64 from the same sources using sfml, such an error does not occur. Perhaps I did something wrong when setting up the compiler?

There are differences in the 32 bit and 64 bit MinGW GCC Compilers.
The main one is how exception handling is done.

You might try turning off exception handling and see if that fixes the issue.

Tim S.
Title: Re: Compiler flags -static-libgcc -static-libstdc++ don't work
Post by: oBFusCATed on May 05, 2020, 07:33:53 pm
@Gnomoron: Are you sure that the compiler you're using supports the flags you're passing to it? As far as I know not all releases do support static linking of the runtime.