elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  porque al compilar pesa tanto un programa?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: porque al compilar pesa tanto un programa?  (Leído 9,523 veces)
Karman


Desconectado Desconectado

Mensajes: 673



Ver Perfil WWW
Re: porque al compilar pesa tanto un programa?
« Respuesta #10 en: 29 Noviembre 2010, 06:45 am »

es por una característica de gcc cuando se utilizan las STL, y es debido a que en este compilador el código del la STL es embebido en el ejecutable final (lo cual no pasa con visual c++ debido a que dichas funcionalidades están en una dll externa), pero no te tiene que importar eso, dado que, al fin y al cabo, ambos pesan lo mismo en memoria (con gcc es un solo módulo, con visual c, son 2 o más)

cita de la página compilador mingw:

Citar
C++ programs using the Standard Template Library (ie/ #include <iostream>) cause a large part of the library to be statically linked into the binary. The need to statically link the stdc++ into the binary is two fold. First MSVCRT.dll does not contain C++ stdlib constructs. Second the legal implications of generating a libstdc++.dll are restricted by the licensing associated with the library. If you wish to keep your file size down use strip to remove debugging information and other verbatim found in the binary.

S2


En línea

bomba1990


Desconectado Desconectado

Mensajes: 395



Ver Perfil WWW
Re: porque al compilar pesa tanto un programa?
« Respuesta #11 en: 29 Noviembre 2010, 17:04 pm »

ahhhhhhh, gracias. voy a averiguar porque debe haber una forma de que no lo linkee porque en el futuro tengo ganas de hacer un troyano cuando aprenda mas c++ y me gustaria que fuera mas liviano. pero de todas maneras muchaaas gracias a todos porque ahora entiendo cual es el problema.

aqui cinsegui esta pagina que lo explica muy bien:

http://www.zator.com/Cpp/E1_4_6.htm


« Última modificación: 29 Noviembre 2010, 17:14 pm por bomba1990 » En línea

"Cuando le di de comer a los pobres me llamaron santo, pero cuando pregunte porque los pobres eran pobres me dijeron comunista"

http://sosinformatico.blogspot.com/
http://www.publisnet.com.ve
APOKLIPTICO


Desconectado Desconectado

Mensajes: 3.871


Toys in the attic.


Ver Perfil
Re: porque al compilar pesa tanto un programa?
« Respuesta #12 en: 29 Noviembre 2010, 17:55 pm »

Ponele las optimizaciones, es raro, porque estoy compilando un programa que linkea un monton de libs, y me pesa 88 k y en debug.
En el modo debug tengo puesta solo la opción x defecto "produce debugging symbols".

En el release, me pesa menos de la mitad.
Tengo puestas las opciones "strip symbols" y "optimize even more".
En línea

AMD Phenom II 1075T X6 @ 290 Mhz x 11 (HT 2036 Mhz NB Link 2616 Mhz) 1.23 Vcore
ASUS M4A89GTD-PRO/USB3
2x2gb G-Skill RipjawsX DDR3 1600 Mhz CL7 (7-8-7-24-25-1T)
Seagate 500 Gb
XFX HD4850 512Mb GDDR3. 650 Mhz/995 Mhz 1.1 Tflops.
bomba1990


Desconectado Desconectado

Mensajes: 395



Ver Perfil WWW
Re: porque al compilar pesa tanto un programa?
« Respuesta #13 en: 29 Noviembre 2010, 19:22 pm »

ya lei bien, lo que pasa es que al linkear iostream el compilador linkea el objeto completo, es decir linkea la libreria estandar completa, en cambio si uso stdio.h el programa no pasa de 25kb.

Citar
Why is the compiled executable file so large?

People usually ask this question when they compile a simple program which uses iostreams. The first thing you can do is to add -s to Project Options - Parameters - Linker, but the result may be still too large for your taste. In this case, either try to live with it (it actually doesn't matter so much!), or avoid iostreams (use cstdio), or use another compiler. Also note that there are some exe compressors on the net, e.g. upx.

The reason why iostream increases the size so much is that the linker links entire object files (from inside of libraries) if they contain at least one necessary reference, and the library for iostream is not well separated into small object files. Also, the linker should be able to link only certain sections of the object files (see "--gc-sections"), but this particular feature doesn't work yet on the mingw target (and that affects all libraries and object files).

Tomado de:  Adrian Sandor www14.brinkster.com
« Última modificación: 29 Noviembre 2010, 19:24 pm por bomba1990 » En línea

"Cuando le di de comer a los pobres me llamaron santo, pero cuando pregunte porque los pobres eran pobres me dijeron comunista"

http://sosinformatico.blogspot.com/
http://www.publisnet.com.ve
Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[b]CON QUE PROGRAMA GRABO DEL DISCO DURO A CD ,CUANDO EL ARCHIVO PESA MAS DE
Software
volko 2 2,440 Último mensaje 2 Abril 2003, 04:19 am
por Bres
Porque el server de el foro falla tanto en la conexion
Sugerencias y dudas sobre el Foro
Valkyr 1 1,829 Último mensaje 25 Agosto 2006, 14:44 pm
por WarGhost
¿Porque se reinicia el programa?
Programación C/C++
skatres 5 3,040 Último mensaje 13 Noviembre 2011, 22:55 pm
por skatres
¿Porque tanto odio y fanatismo hacia Apple? « 1 2 3 »
Foro Libre
crazykenny 21 10,228 Último mensaje 22 Mayo 2014, 18:33 pm
por daryo
Porque explotan tanto a las mujeres en los medios
Foro Libre
Flamer 6 3,398 Último mensaje 30 Noviembre 2020, 15:21 pm
por Flamer
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines