G ++ creates large binaries despite a small project

Perhaps this is a general question. In fact, I think I asked him many years ago ... but I can’t remember the answer.

Problem: I have a project consisting of 6 source files. All of them are no more than 200 lines of code. It uses many STL containers, stdlib.h and iostream. Now the executable file has a size of about 800 KB ... I think I should not statically link libraries. How to do this with GCC? What about the Eclipse CDT?

EDIT: Since I am responding to what I want, I think this is a matter of clarification. I want to know why such a small program is so large in size, and what is the relationship with static, shared libraries and their difference. If this is too long a story to tell, feel free to give pointers to documents. thank you

+3
source share
7 answers

If you give the names of the g ++ dynamic library and do not pass the flag -static, it must be dynamically linked.

To reduce the size, you could, of course, stripcreate a binary file, and pass the optimization flag -Os(optimize size) to g++.

+2
source

, STL , ++. , STL - , , . , , . STL.

, , , . .

+2

Eclipse , makefile.

EDIT:

- , , .
, , .

+1

.

, , , , .

, . , , .

. , .

, ? 800 - ! . , , 1600KB. , 810 - .

.

+1

-O3 -s . . .

Windows, Microsoft. .

0

, .

, RELEASE, .

. , , STD, , C Runtime , . .

, , , : x86 ELF Hello World

0

Visual ++ 6.0 Windows 95 Windows 7. x86, Windows. , Windows, Windows, GCC, sux. , , Visual ++ sux, Anti-Microsofters. , "Visual ++ 6.0", , , Windows 95. , . GCC , Visual ++ , Intel Compiler 30% , Intel, . , , - , , . , C, C , OO infact C , ++ , ++

cout <"Hello World" <cps; printf ("% s", "Hello World");

second one say print field% s means you enter the string so that it is easy .: P

-5
source

Source: https://habr.com/ru/post/1724283/


All Articles