Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: va!n on January 20, 2009

Title: VS settings for creating smallest application?
Post by: va!n on January 20, 2009
hi guys...
can someone of you tell me, what options/settings must/should be changed in VS2005/VS2008 to produce the smallest unpacked and legal Win32 executeable? This has nothing directly to do with intro coding... just would like to have a tiny framework for creating no bloody GUI appz and know how and where to change the settings ^^ thx

example source with prj file attached...
Title: Re: VS settings for creating smallest application?
Post by: benny! on January 20, 2009
@va!n:
I do not know any software development field in which
they focused as much on size reducing a window exe as
they do in the scene. Since you already released some
tiny production - I guess you know all the compiler settings
already.

Just don't include what you do not need if you want to
aim for anything else than a graphic fx exe.
Title: Re: VS settings for creating smallest application?
Post by: va!n on January 20, 2009
@benny:
i have tried to play a bit with the compiler settings to reduce its size... no luck...
and i have tried to use the DX framework for GUI coding but has some probs...

however, using a framework with a given projectfile is nice but personally i would like to know / learn now, what and where to change settings... for example i have tried to replace on working sources the "WindowsMainCRTStartup" by "WinMain" but then i ended in lot of errors... so i dont really know the different and what i have to check when doing this.

At least i think it makes more sence when me and possible other guys know where and what settings they can/should use instead just using a given project file...

Title: Re: VS settings for creating smallest application?
Post by: Jim on January 20, 2009
4Kb is the smallest 'valid' Windows exe.

To make things small, you need to turn on optimise for size, turn off link time code generation, and turn off default libraries in the compiler and linker.

main() is the entry point for Win32 Console apps
WinMain() is the entry point for Win32 windowed apps.

If you're not using the C runtime (ie. no default libraries) then the entry points are
mainCRTStartup()
WinMainCRTStartup()

If you're coding C then make sure your files end with .c
If you're coding C++ then make sure your files end with .cpp

If you want DirectX then you need to go into the linker settings and add to the additional libraries.
Usually you need d3d9.lib.
Other ones might be opengl32.lib winmm.lib dxguid.lib d3dx9.lib depending what you want.

Jim
Title: Re: VS settings for creating smallest application?
Post by: benny! on January 20, 2009
@va!n:
Ok .. fair enough.

This might be a bit outdated (VC6.0) but maybe it
helps a bit, too.

http://www.hailstorm.net/papers/smallwin32.htm#compiler (http://www.hailstorm.net/papers/smallwin32.htm#compiler)