Author Topic: Problem with standalone exe  (Read 681 times)

Offline bad_terminal

  • Single posting newcomer
  • *
  • Posts: 1
Problem with standalone exe
« on: October 26, 2025, 10:31:14 pm »
Good evening,

So I've been using CodeBlocks for a number of years while attempting to learn C++. However, after a recent re-installation of 20.03, I noticed that while my programs compile in the editor, the exe's they produce are smaller than usual (215kb v 2487kb), and the standalone exe will not run.

If my understaniding is correct, it's because certain compiler flags weren't set.

Now, whilst I appear to have remedied this, what would cause this to happen? Are those flags not set as default with a fresh installation? I installed 20.03 the first time so long I don't remember having to set flags.

For anyone else having the same problem , the flags I had to set were -static -static-libgcc -static-libstdc++   in the compiler flags section

Also, in the global compiler section. there are numerous things to 'set' eg, C++ compiler , linker for dynamic libs, linker for static libs, resource compiler, make program.

I've set all these to x86_64-w64-mingw32-g++.exe, but really have no idea what any of them are meant to be set to, and/or what the effects of using different (but similarly named) compliers would have.

Please advise.
Thankyou.

So several days and no replies? A veritable hive of activity! Surely somebody knows what all those different 'compliers' are and what the difference is?
« Last Edit: October 29, 2025, 01:34:30 pm by bad_terminal »

Offline gd_on

  • Lives here!
  • ****
  • Posts: 832
Re: Problem with standalone exe
« Reply #1 on: October 30, 2025, 07:32:32 pm »
have a look to https://stackoverflow.com/questions/1993390/static-linking-vs-dynamic-linking
And add in your PATH system variable, the path to "your compiler\bin" sub-folder (where is located your gcc.exe or g++.exe) : may be something like C:\MinGW64\bin or C:\Program Files\CodeBlocks\MinGW\bin or something else. Code::Blocks, for its own usage, know that path. Bur for a standalone executable, build dynamically (with dlls) you have to help a little bits Windows.
« Last Edit: October 30, 2025, 07:42:46 pm by gd_on »
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.1, Msys2 Compilers 15.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).