I've finally come to know, and shall I add accidentally, the difference between Debug build and Release Build when I posted something in the Windows programming forum.
Turns out that a Debug build is much larger than a Release build. To my enthuiasm, I tried a simple "hello world!" program and compiled it using MinGW but gave me around 217KB! I remembered back when I was kid and did simple calculators using VB6, my .exe s were around 60KB of size, but that was VB!
Now it was pointed to me in the original thread that even a very simple WIN API application could compile to 7KB!
So why am I getting a 217KB "hello world!" program?
It sounds to me like you're linking statically (i.e. you are including all the library functions you use in your compiled code, instead of calling them from the dynamic libraries at runtime).
There is no strict definition of the difference between the debug and release versions. You can change the settings yourself.
As a general rule of thumb, the debug version will not include optimisations for speed or size and will include additional information such as debugging symbols. Also, in debug mode variables are often set to values that are either sensible or helpful; this will of course entail additional size. To see exactly what's happening in your build, find the settings and see what difference switches and values are fed into the compiler and linker in the release and static builds.
Here is a hello world program that I just compiled:
The smallest "hello world" type executable I ever saw on a modern OS (which actually just returned a value, rather than writing "hello world") was 45 bytes and was an ELF executable. I was very impressed. :)
Let me get this straight, say I use dynamic building for a very simple program that happens to use say, stdlib.h. So when I run the executable that happens to be in the build directory, it won't work unless there's a supporintg dll?
here are some options I've found relevent in under the compiler settings for a release build:
*optimize generated code (for speed)
*optimize more (for speed)
*optimize even more (for speed) (this box was checked)
*optimize fully (for speed)
*optimize generated code (for size)
*expensice optimizations
I checked "optimeze generated code (for size)" but after build I still got an expensive 265KB for the hello world!
I couldn't find dynamic building or static building anywhere, but when I created the project I chose Release version only...
C, and even more so C++, are designed to build medium/large programs. They're just not designed for making tiny programs. The actual code generated is as small as it gets, but the library support that you pull in isn't.
C has per thread statics for error, time, atexit support and so on. C++ has all that plus support for constucting global objects and a few global objects of its own, plus support for exceptions and RTTI.
You can provide your own start up code that is unencumbered, and coupled with calling system calls instead of lubrary functions, you can make tiny programs.
See Matt Peitrek's LIBTINYC for an example under Windows.
EDIT: Oh, and I forgot the title. Debug uses a debug heap, that adds markers around each allocated block to detect block overwrite errors and routines and data for debugging heap errors. Typically Debug builds with more run-time checks and Release defines NDEBUG.
Does Windows have these DLLs lying around somewhere? I mean suppose I create a program that adds registry info from a .reg file to my registry, and it uses some sort of header file or library, say stdio.h, and it is supposed to be an executable because I need to carry it around. Would it work? Would it search for something like stdio.dll somewhere in Windows folder or what?
I've seen a 60KB exutable that does that, but the Win32 console just flashed for a second, after that, the job was done...
Does Windows have these DLLs lying around somewhere?
What DLLs?
You access the Windows Regstry using the Windows Platform API. The header file is Windows.h. There are a number of system libraries that implement the API. How else could you access the registry?
See Matt Peitrek's LIBTINYC for an example under Windows.
wow kbw he must have made this so many moons ago. if its the same one i believe it was made over 10 years ago and still valid code to this day. i remember reading about it so long ago. amazing its still around to this day