CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Why is my release exe 32 kb with only 14 lines of code?

    Quote Originally Posted by Craisins View Post
    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.

    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
    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.
    Last edited by Igor Vartanov; February 8th, 2010 at 04:58 PM.
    Best regards,
    Igor

  2. #17
    Join Date
    Feb 2010
    Posts
    42

    Re: Why is my release exe 32 kb with only 14 lines of code?

    Quote Originally Posted by Lindley View Post
    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.
    Last edited by Craisins; February 8th, 2010 at 07:57 PM.

  3. #18
    Join Date
    Feb 2010
    Posts
    42

    Re: Why is my release exe 32 kb with only 14 lines of code?

    Quote Originally Posted by Igor Vartanov View Post
    Sure it will, by twelve years afraid though.
    The /MD actually cut the file size by 80-90&#37;! If I use it in VC6.0, the program should still be able to run in XP and above without those dependency errors?
    Last edited by Craisins; February 8th, 2010 at 07:56 PM.

  4. #19
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Why is my release exe 32 kb with only 14 lines of code?

    Quote Originally Posted by Craisins View Post
    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.[/
    Last edited by Arjay; February 8th, 2010 at 08:55 PM.

  5. #20
    Join Date
    Feb 2010
    Posts
    42

    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.
    Last edited by Craisins; February 8th, 2010 at 09:54 PM.

  6. #21
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Why is my release exe 32 kb with only 14 lines of code?

    Quote Originally Posted by Craisins View Post
    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.

  7. #22
    Join Date
    Apr 1999
    Posts
    65

    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.

  8. #23
    Join Date
    Feb 2010
    Posts
    42

    Re: Why is my release exe 32 kb with only 14 lines of code?

    Quote Originally Posted by anuvk View Post
    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.

  9. #24
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    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..
    Best regards,
    Igor

  10. #25
    Join Date
    Feb 2010
    Posts
    42

    Re: Why is my release exe 32 kb with only 14 lines of code?

    Quote Originally Posted by Igor Vartanov View Post
    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.

  11. #26
    Join Date
    Feb 2005
    Posts
    2,160

    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.

  12. #27
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    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?

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured