#141215 - Moby Disk - Sun Sep 23, 2007 7:16 am
I took one of the palib demo applications and I renamed the file extension from .c to .cpp. The resulting output file went from 79k to 135k. I assume g++ is linking in some unnecessary libraries, but then the linker should remove them if they aren't used. Anybody know what this is? It shouldn't be debug info since I added -g0 to the Makefile.
If I add #include <iostream> it goes up to 389k. Now that's just silly.
By comparison, a basic C++ console application using iostream on Windows compiled with MSVC 2005 is 108k.
#141234 - kusma - Sun Sep 23, 2007 11:35 am
try adding -fno-rtti and -fno-exceptions to your compile-flags...
#141240 - Sunray - Sun Sep 23, 2007 1:14 pm
If you declare static variables inside functions then compile with -fno-threadsafe-statics to reduce the code size significantly.
#141242 - Moby Disk - Sun Sep 23, 2007 1:44 pm
Tried both, no help. But they are good to know for the future. Just for reference, here is the main.cpp:
#include <iostream>
int main(int argc, char ** argv)
{
return 0;
}
Although I didn't scrub the libnds libraries out of the Makefile, but I don't think that is it since 95% of the space appears when I add #include <iostream>
I thought ld would remove unused dependencies. Perhaps ld is unable to do that with the iostream functions for some reason? Maybe I should try this under some other OS. Could it be a gcc/ld issue.
#141291 - Dood77 - Sun Sep 23, 2007 9:06 pm
iostream is known to add a ton more overhead than stdio...
_________________
If I use a term wrong or something then feel free to correct, I?m not much of a programmer.
Original DS Phat obtained on day of release + flashme v7
Supercard: miniSD, Kingston 1GB, Kingston 2GB
Ralink chipset PCI NIC
#141367 - sajiimori - Mon Sep 24, 2007 6:49 pm
iostream declares static objects that are initialized before entering main(). The constructors for those objects are therefore always referenced, and the constructors apparently cause just about everything else to link in.
iostream is a beast -- I'd avoid it for game dev.