Comments (3)
Please provide (1) the GCC versions you are comparing (TDM-GCC, MinGW64); (2) the command-line flags you are using.
TDM-GCC statically links libgcc and libstdc++ into your executables by default, which increases their total size but is still smaller than the size of the executable plus libgcc.dll plus libstdc++.dll. You can link to the DLLs if you prefer with "-shared-libgcc -shared-libstdc++".
Versions of GCC from 4.7 and earlier produce smaller C++-based executables by default.
from tdm-gcc-src.
from tdm-gcc-src.
Unfortunately you haven't provided enough information about the file you're compiling and the flags you're using when you compile, so I can only say, I agree that certain programs are shockingly large when compiled with GCC and I hope the GCC and MinGW-w64 maintainers will spend some time optimizing for size at some point.
In the meantime, here is a size-optimized hello world, and I recommend doing more research on how to optimize for size on Google and in GCC's online documentation.
C:\crossdev\tests>type hello.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hello, world!" << endl;
cout << "Hello, my darling!" << endl;
cout << "Hello, my friends!" << endl;
return 0;
}
C:\crossdev\tests>"C:\TDM-GCC-64-9.2.0\bin\g++.exe" -o hello.exe hello.cpp -Os -s -flto -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections
C:\crossdev\tests>dir hello.exe
Volume in drive C has no label.
Volume Serial Number is EC0D-4807
Directory of C:\crossdev\tests
05/20/2021 06:19 PM 920,064 hello.exe
from tdm-gcc-src.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tdm-gcc-src.