Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to compile .exe without trash ?

How to compile .exe without trash ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++announcementdebuggingtutorialquestion
9 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mirex
    wrote on last edited by
    #1

    When I compile any of mine projects with MS Visual C++ 6.0 there is alot of trash inside .exe file. Its looking like debug information although I'm building a release version (there are lots paths and filenames inside executable clearly viewable). How to remove it all, to reduce .exe size ? Why is it there ?

    B 1 Reply Last reply
    0
    • M mirex

      When I compile any of mine projects with MS Visual C++ 6.0 there is alot of trash inside .exe file. Its looking like debug information although I'm building a release version (there are lots paths and filenames inside executable clearly viewable). How to remove it all, to reduce .exe size ? Why is it there ?

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      Exactly how are you viewing the .exe? with a hex viewer? I know that you can still usually find strings in most .exe's using the Win32 disassembler, (I think that's how some people find a message like "you have entered an invalid code" and use a hex viewer to change the 'jmp' statement to a 'nop'... or so I hear :suss: ). If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice

      M 1 Reply Last reply
      0
      • B BlackDice

        Exactly how are you viewing the .exe? with a hex viewer? I know that you can still usually find strings in most .exe's using the Win32 disassembler, (I think that's how some people find a message like "you have entered an invalid code" and use a hex viewer to change the 'jmp' statement to a 'nop'... or so I hear :suss: ). If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice

        M Offline
        M Offline
        mirex
        wrote on last edited by
        #3

        Yup I view it with hexviewer, but i bet it is visible with notepad too :) Yea you can crack programs by hexviewers, but disassemblers / hexview+dissaembler (like HIEW or DN) are better, trust me. But anyhow, question is how to compile without the trash ? Now anyone can see my developement directories, and it grows my .exe too much. Is there some compiler switch or something ?

        B 1 Reply Last reply
        0
        • M mirex

          Yup I view it with hexviewer, but i bet it is visible with notepad too :) Yea you can crack programs by hexviewers, but disassemblers / hexview+dissaembler (like HIEW or DN) are better, trust me. But anyhow, question is how to compile without the trash ? Now anyone can see my developement directories, and it grows my .exe too much. Is there some compiler switch or something ?

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          Yes, you need to disable the inclusion of the information for the PDB files. Go to the Project menu and select settings. A tabbed dialog called 'Project Settings' appears. Make sure, on the left, the 'settings for' is set to something like "Win32 Release". Go to tab marked 'Link'. In 'Category' drop list box select 'Debug'. Under 'Debug Info' group, make sure the 'Debug Info' check box is NOT checked. Go to the 'C/C++' tab. In 'Category' drop list box select 'Preprocessor'. In the edit field 'Preprocessor definitions' make sure you see NDEBUG. If it is missing, then add it to end of list of other options. If you see DEBUG or _DEBUG in the list of items, then remove it. That should help.

          M 1 Reply Last reply
          0
          • B Blake Miller

            Yes, you need to disable the inclusion of the information for the PDB files. Go to the Project menu and select settings. A tabbed dialog called 'Project Settings' appears. Make sure, on the left, the 'settings for' is set to something like "Win32 Release". Go to tab marked 'Link'. In 'Category' drop list box select 'Debug'. Under 'Debug Info' group, make sure the 'Debug Info' check box is NOT checked. Go to the 'C/C++' tab. In 'Category' drop list box select 'Preprocessor'. In the edit field 'Preprocessor definitions' make sure you see NDEBUG. If it is missing, then add it to end of list of other options. If you see DEBUG or _DEBUG in the list of items, then remove it. That should help.

            M Offline
            M Offline
            mirex
            wrote on last edited by
            #5

            Thank you, but actually it didnt, because all those things were like that from the start, those are default Release settings. :(

            B 1 Reply Last reply
            0
            • M mirex

              Thank you, but actually it didnt, because all those things were like that from the start, those are default Release settings. :(

              B Offline
              B Offline
              Blake Miller
              wrote on last edited by
              #6

              I forgot to mention one more that might be different. On the Project Settings : C/C++ with the drop down list box set to "General" There is a 'debug info' drop down list box and that should be set to 'None'. Since you said that it seems all the file paths are in your EXE, maybe this is set to 'Program Database' for your project. I can't really think of another reason all the source paths are in your EXE unless someone has put something like static char s_FilePath[] = __FILE__; in all of your source files, which would automatically cause them all to be included.

              M 1 Reply Last reply
              0
              • B Blake Miller

                I forgot to mention one more that might be different. On the Project Settings : C/C++ with the drop down list box set to "General" There is a 'debug info' drop down list box and that should be set to 'None'. Since you said that it seems all the file paths are in your EXE, maybe this is set to 'Program Database' for your project. I can't really think of another reason all the source paths are in your EXE unless someone has put something like static char s_FilePath[] = __FILE__; in all of your source files, which would automatically cause them all to be included.

                M Offline
                M Offline
                mirex
                wrote on last edited by
                #7

                Yup 'debug info' was set to 'none' Of course im not using "static char s_FilePath[] = __FILE__;" that would be pretty dumb :) why would I need absolute path to my project in the proggy :) generally absolute paths are bad thing. Uh oh then ...

                B 1 Reply Last reply
                0
                • M mirex

                  Yup 'debug info' was set to 'none' Of course im not using "static char s_FilePath[] = __FILE__;" that would be pretty dumb :) why would I need absolute path to my project in the proggy :) generally absolute paths are bad thing. Uh oh then ...

                  B Offline
                  B Offline
                  Blake Miller
                  wrote on last edited by
                  #8

                  Take most C++ files generated by MFC AppWizards and you will find code similar to this at top of every source file... #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif So.... Why would you want to do that? These are the only reasons I could locate... #define TRACE ::AfxTrace #define THIS_FILE __FILE__ #define ASSERT(f) \ do \ { \ if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \ AfxDebugBreak(); \ } while (0) \ #define VERIFY(f) ASSERT(f) #define ASSERT_VALID(pOb) (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__)) #define DEBUG_ONLY(f) (f) // Memory tracking allocation void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine); #define DEBUG_NEW new(THIS_FILE, __LINE__) #if _MSC_VER >= 1200 void AFX_CDECL operator delete(void* p, LPCSTR lpszFileName, int nLine); #endif #ifdef _DEBUG #define DAO_CHECK(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__) #define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, err) #define DAO_CHECK_MEM(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, \ NO_AFX_DAO_ERROR, TRUE) #define DAO_TRACE(f) AfxDaoTrace(f, #f, THIS_FILE, __LINE__) #else #define DAO_CHECK(f) AfxDaoCheck(f, NULL, NULL, 0) #define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, NULL, NULL, 0, err) #define DAO_CHECK_MEM(f) AfxDaoCheck(f, NULL, NULL, 0, \ NO_AFX_DAO_ERROR, TRUE) #define DAO_TRACE(f) f #endif Anyways, I mentioned it in case you had included a macro in some header file that had something similar to a statement such as that, so your full file path was ending up as a static variable in every source file.

                  M 1 Reply Last reply
                  0
                  • B Blake Miller

                    Take most C++ files generated by MFC AppWizards and you will find code similar to this at top of every source file... #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif So.... Why would you want to do that? These are the only reasons I could locate... #define TRACE ::AfxTrace #define THIS_FILE __FILE__ #define ASSERT(f) \ do \ { \ if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \ AfxDebugBreak(); \ } while (0) \ #define VERIFY(f) ASSERT(f) #define ASSERT_VALID(pOb) (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__)) #define DEBUG_ONLY(f) (f) // Memory tracking allocation void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine); #define DEBUG_NEW new(THIS_FILE, __LINE__) #if _MSC_VER >= 1200 void AFX_CDECL operator delete(void* p, LPCSTR lpszFileName, int nLine); #endif #ifdef _DEBUG #define DAO_CHECK(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__) #define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, err) #define DAO_CHECK_MEM(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, \ NO_AFX_DAO_ERROR, TRUE) #define DAO_TRACE(f) AfxDaoTrace(f, #f, THIS_FILE, __LINE__) #else #define DAO_CHECK(f) AfxDaoCheck(f, NULL, NULL, 0) #define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, NULL, NULL, 0, err) #define DAO_CHECK_MEM(f) AfxDaoCheck(f, NULL, NULL, 0, \ NO_AFX_DAO_ERROR, TRUE) #define DAO_TRACE(f) f #endif Anyways, I mentioned it in case you had included a macro in some header file that had something similar to a statement such as that, so your full file path was ending up as a static variable in every source file.

                    M Offline
                    M Offline
                    mirex
                    wrote on last edited by
                    #9

                    Thank you ... Im not using Dao so I hope that last part of code does not apply to me. And I though that all asserts are turned off in Release version (through #ifdef _DEBUG) ... sigh, so looks like its hopeless

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups