Author Topic: Compiler flags -static-libgcc -static-libstdc++ don't work  (Read 5549 times)

Offline Gnomoron

  • Single posting newcomer
  • *
  • Posts: 7
Hello everyone!

I use nighty build (12072) 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.
« Last Edit: May 05, 2020, 10:15:49 am by Gnomoron »


Offline Gnomoron

  • Single posting newcomer
  • *
  • Posts: 7
Re: Compiler flags -static-libgcc -static-libstdc++ don't work
« Reply #2 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))

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1560
Re: Compiler flags -static-libgcc -static-libstdc++ don't work
« Reply #3 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.

Offline Gnomoron

  • Single posting newcomer
  • *
  • Posts: 7
Re: Compiler flags -static-libgcc -static-libstdc++ don't work
« Reply #4 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?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1560
Re: Compiler flags -static-libgcc -static-libstdc++ don't work
« Reply #5 on: May 05, 2020, 12:37:23 pm »
Compare the buid logs; in the one you posted the -static flag is missing.

Offline Gnomoron

  • Single posting newcomer
  • *
  • Posts: 7
Re: Compiler flags -static-libgcc -static-libstdc++ don't work
« Reply #6 on: May 05, 2020, 02:56:25 pm »
-static didn't help :c

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Compiler flags -static-libgcc -static-libstdc++ don't work
« Reply #7 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Compiler flags -static-libgcc -static-libstdc++ don't work
« Reply #8 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]