i noticed that mingw adds alot of code before calling main(), i assumed its for parsing command line parameters since one of those functions is called __getmainargs(), and also lots of strings are added to the final executable, such as mingwm.dll and some error strings (incase the app crashed) says mingw runtime error or something like that.
my question is: is there a way to remove all this stuff? i dont need all these things, i tried tcc (tiny c compiler) it did the job. but not cross platform like gcc (solaris/mac)
any ideas?
thanks.
Yes, you really do need all those things. They’re the startup and teardown code for the C environment that your code runs in.
Other than non-hosted environments such as low-level embedded solutions, you’ll find pretty much all C environments have something like that. Things like
/lib/crt0.ounder some UNIX-like operating systems orcrt0.objunder Windows.They are vital to successful running of your code. You can freely omit library functions that you don’t use (
printf,absand so on) but the startup code is needed.Some of the things that it may perform are initialisation of
atexitstructures, argument parsing, initialisation of structures for the C runtime library, initialisation of C/C++ pre-main values and so forth.It’s highly OS-specific and, if there are things you don’t want to do, you’ll probably have to get the source code for it and take them out, in essence providing your own cut-down replacement for the object file.