Re: Why is my release exe 32 kb with only 14 lines of code?
Quote:
Originally Posted by
Craisins
Debug is much bigger and release is around 32kb. What can be done to get VC2008 style cleanup?
Nothing special, you know. You just spend a few years to learn C++, and magic comes ultimately. :D
35.cpp here below is your 14 lines. Look what good /MD switch brings in. :)
Code:
D:\Temp\35>cl 35.cpp user32.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
35.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:35.exe
35.obj
user32.lib
D:\Temp\35>dir
Volume in drive D is WORK
Volume Serial Number is 4067-668D
Directory of D:\Temp\35
02/09/2010 12:45 AM <DIR> .
02/09/2010 12:45 AM <DIR> ..
02/09/2010 12:45 AM 284 35.cpp
02/09/2010 12:51 AM 45,056 35.exe
02/09/2010 12:45 AM 382 35.exe.manifest
02/09/2010 12:51 AM 803 35.obj
4 File(s) 46,525 bytes
2 Dir(s) 37,164,232,704 bytes free
Code:
D:\Temp\35>cl 35.cpp /MD user32.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
35.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:35.exe
35.obj
user32.lib
D:\Temp\35>dir
Volume in drive D is WORK
Volume Serial Number is 4067-668D
Directory of D:\Temp\35
02/09/2010 12:45 AM <DIR> .
02/09/2010 12:45 AM <DIR> ..
02/09/2010 12:45 AM 284 35.cpp
02/09/2010 12:45 AM 5,632 35.exe
02/09/2010 12:45 AM 382 35.exe.manifest
02/09/2010 12:45 AM 950 35.obj
4 File(s) 7,248 bytes
2 Dir(s) 37,164,273,664 bytes free
Quote:
Only reason I switched to VC6 is because VC2008 required some computers to have MSVC90.dll as a runtime library and is very annoying to the end user to have to install that, so I chose VC6. I wish 2008 had a way to build exe as VC6 does however.
Sure it will, by twelve years afraid though.
Re: Why is my release exe 32 kb with only 14 lines of code?
Quote:
Originally Posted by
Lindley
If you set your VS2008 project to link the runtime library statically, then the DLL should not be required (but the exe size may be slightly larger).
Wait really? How do I link MSVC90.dll statically??? Am I typing /MD or /CRT somewhere? And how big of a exe file size jump are we talking about if we link statically?
@ everybody else: thank you for the great tips, I am testing them all right now!
And about going back to 2008, I will go back to it once I figure out how to statically link the DLL it requires so that those errors do not pop up.
Re: Why is my release exe 32 kb with only 14 lines of code?
Quote:
Originally Posted by
Igor Vartanov
Sure it will, by twelve years afraid though.
The /MD actually cut the file size by 80-90%! If I use it in VC6.0, the program should still be able to run in XP and above without those dependency errors?
Re: Why is my release exe 32 kb with only 14 lines of code?
Quote:
Originally Posted by
Craisins
If I use it in VC6.0, the program should still be able to run in XP and above without those dependency errors?
It sounds like you are looking at the wrong approach.
Hoping that a 12 year old set of vc dlls remain on the OS is just asking for trouble because there is no guarantee that the VC dlls will be available in future OS versions.
The smart way to approach this would be to:
1) Statically link
2) Create an install program that installs the necessary dependencies.[/
Re: Why is my release exe 32 kb with only 14 lines of code?
I am coding ONLY for XP and Vista though, its a simple app and anything past Vista or below XP is not my target for this release, and is also not necessary, just trust me on
that part :P.
Re: Why is my release exe 32 kb with only 14 lines of code?
Quote:
Originally Posted by
Craisins
Wait really? How do I link MSVC90.dll statically???
I don't have 2008, but if it's at all similar to 2005, then there's an option in the project properties, under C/C++ -> Code Generation. There should be four options in a drop-down menu: Multithreaded, Multithreaded Debug, and two DLL variants of those. Choosing one of the non-DLL versions will statically link the runtime library.
Re: Why is my release exe 32 kb with only 14 lines of code?
If size is a concern and just a Mesagebox is what you need to display
-C/C++->Advanced->Compile as C Code
- Linker->Input->YES/(NODEFAULTLIBS)
i.e donot use CRT, remove the string class reference. build as C code, the size of exe will be around 4 KB in release mode.
Re: Why is my release exe 32 kb with only 14 lines of code?
Quote:
Originally Posted by
anuvk
If size is a concern and just a Mesagebox is what you need to display
-C/C++->Advanced->Compile as C Code
- Linker->Input->YES/(NODEFAULTLIBS)
i.e donot use CRT, remove the string class reference. build as C code, the size of exe will be around 4 KB in release mode.
Its not just messagebox, its around 1000 lines of code but I was wondering why the filesize was so huge with only messagebox and string. After enabling /MD all works well though, 32kb before UPX compression. I was gonna convert all strings to char but then it got complicated when I needed to join two to ten char arrays together and stuff.
Re: Why is my release exe 32 kb with only 14 lines of code?
Okay, I was waiting all the time the question: why /MD produses such an effect? what I pay for the shrinking? Is it a trap? And I waited in vain. There were only cheers with no trying to understand implications. That's so sad, you know..
Re: Why is my release exe 32 kb with only 14 lines of code?
Quote:
Originally Posted by
Igor Vartanov
Okay, I was waiting all the time the question: why /MD produses such an effect? what I pay for the shrinking? Is it a trap? And I waited in vain. There were only cheers with no trying to understand implications. That's so sad, you know..
Because, I've already researched /MD myself on MSDN, but if you really wanted to answer it please do, I'm sure you'll explain it much better since MSDN is sometimes a pain to understand. Please, tell me :), why does /MD produce such a small file size, and what are the implications? The switch was /MLd before I changed to /MD.
Re: Why is my release exe 32 kb with only 14 lines of code?
/MT Multi-threaded (statically linked)
/MTd (same as above only "debug")
/MD Multi-threaded DLL (dynamically linked)
/MDd (same as above only "debug")
"Statically linked" means that the runtime libraries are linked to the final exe (lots of extra bloat). "Dynamically linked" means that the runtime libraries are in a separate dll and it only appears that your exe is smaller, but it will need the runtime dlls and "dll hell" may ensue.
Re: Why is my release exe 32 kb with only 14 lines of code?
I think the real question is...
Why is this thread larger than my source code?