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

Offline bad_terminal

  • Single posting newcomer
  • *
  • Posts: 4
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).

Offline nenin

  • Almost regular
  • **
  • Posts: 245
Re: Problem with standalone exe
« Reply #2 on: Yesterday at 07:47:55 am »
Surely somebody knows what all those different 'compliers' are and what the difference is?
I know. It is different compilers for the different cases. I have 3 compilers in use: one for Win64 (gcc 14.2, default), one for Win32 (gcc 14.2 for some automation tasks, old hardware has no Win64 drivers) and one for XP (gcc 9.3, really old hardware, no Win7 drivers).

Offline bad_terminal

  • Single posting newcomer
  • *
  • Posts: 4
Re: Problem with standalone exe
« Reply #3 on: Today at 01:32:04 pm »
Surely somebody knows what all those different 'compliers' are and what the difference is?
I know. It is different compilers for the different cases. I have 3 compilers in use: one for Win64 (gcc 14.2, default), one for Win32 (gcc 14.2 for some automation tasks, old hardware has no Win64 drivers) and one for XP (gcc 9.3, really old hardware, no Win7 drivers).

Ok thankyou, that makes sense.