User forums > General (but related to Code::Blocks)

Mystery of the executable size

(1/3) > >>

Krice:
Almost exactly ten years ago I released the last version of Brick Atelier (a pixel art program). I compiled it with C::B and the size of .exe back then was 232Kb. Now ten years later and about 10K more lines added to the project I'm trying to compile it again, but something is different. When I compiled without static linking the size of .exe is 282Kb (by the way, the old version was 32bit and this new one is 64bit). However it wont run, because it requires libgcc_s_seh-1.dll, libstdc++-6.dll and libwinpthread-1.dll. You can add first two dlls with -static-libgcc and -static-libstdc++ flags. However static linking was not needed in the old version and no dlls were needed either.

When you statically link with those the .exe size is now 1027Kb so considerably larger than before, even with 32 to 64 bit difference. And I'm still missing that thread library, which, if someone knows how to statically link it can give me some advice how to do it. I'm now wondering how the linking worked in the old version 10 years ago? It must have been statically linked by default, right? And why the size difference, because the program is more or less same, with new features sure, but it's not that different.

nenin:

--- Quote from: Krice on July 02, 2023, 07:15:25 am --- And I'm still missing that thread library, which, if someone knows how to statically link it can give me some advice how to do it.

--- End quote ---
You can try "-static", it should link all "standard" stuff statically.

Krice:
-static results to error messages, I guess it's trying to statically link SDL2 library also, which seems to fail.

nenin:

--- Quote from: Krice on July 03, 2023, 09:24:49 am ----static results to error messages, I guess it's trying to statically link SDL2 library also, which seems to fail.

--- End quote ---
It should not be like this. You can try explicitly add SDL2 .dll, not .a, to list of the required libraries and test like this.
In general I have observations that for the new gcc lib should have name like *.dll.a to link dll. However, gcc can link dll directly.

ollydbg:

--- Quote ---When you statically link with those the .exe size is now 1027Kb so considerably larger than before, even with 32 to 64 bit difference. And I'm still missing that thread library, which, if someone knows how to statically link it can give me some advice how to do it.
--- End quote ---

If I remember correctly, the libwinpthread-1.dll (thread library) is only allowed to be linked dynamically. I guess you are using mingw64 based gcc? maybe the gcc inside msys2/mingw64.

Navigation

[0] Message Index

[#] Next page

Go to full version