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. (SOLVED) make single executable file in vs2008 (MFC)

(SOLVED) make single executable file in vs2008 (MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpannouncementtutorial
12 Posts 5 Posters 0 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.
  • J Offline
    J Offline
    jawadali477
    wrote on last edited by
    #1

    hi, i have developed program using MFC in vs2008 and now trying to build single executable file (.exe file) so that it can be used on other PCs. my source file contains both .c and .cpp files. i have tried to compile/build the program in Release mode but getting errors like:

    fatal error C1853: 'Release\readtxtfile.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

    so i changed the properties of precompiled header from Use Precompiled Header (/Yu) to Create Precompiled Header (/Yc) and now i'm getting errors like:

    error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file

    can anyone help me in this regard. i.e how to make executable file with source file containing both .c and .cpp files. Regards Jawad

    P S L U 4 Replies Last reply
    0
    • J jawadali477

      hi, i have developed program using MFC in vs2008 and now trying to build single executable file (.exe file) so that it can be used on other PCs. my source file contains both .c and .cpp files. i have tried to compile/build the program in Release mode but getting errors like:

      fatal error C1853: 'Release\readtxtfile.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

      so i changed the properties of precompiled header from Use Precompiled Header (/Yu) to Create Precompiled Header (/Yc) and now i'm getting errors like:

      error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file

      can anyone help me in this regard. i.e how to make executable file with source file containing both .c and .cpp files. Regards Jawad

      P Offline
      P Offline
      pasztorpisti
      wrote on last edited by
      #2

      This precompiled header setting isn't a per-project setting. Set it to "Use Precompiled Header" in the project and inherit this setting in all your .c and .cpp files. After this open the properties windows individually for your stdafx.cpp file and set its precompiled header setting to "Create Precompiled Header". The next step is to select all .c files and open the properties window for them and set the precompiled header setting to "Not Using Precompiled Header". Make sure that you don't include stdafx.h in your .c source files.

      J 1 Reply Last reply
      0
      • J jawadali477

        hi, i have developed program using MFC in vs2008 and now trying to build single executable file (.exe file) so that it can be used on other PCs. my source file contains both .c and .cpp files. i have tried to compile/build the program in Release mode but getting errors like:

        fatal error C1853: 'Release\readtxtfile.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

        so i changed the properties of precompiled header from Use Precompiled Header (/Yu) to Create Precompiled Header (/Yc) and now i'm getting errors like:

        error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file

        can anyone help me in this regard. i.e how to make executable file with source file containing both .c and .cpp files. Regards Jawad

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        Delete the .pch file, it's not a source file.

        Steve

        1 Reply Last reply
        0
        • J jawadali477

          hi, i have developed program using MFC in vs2008 and now trying to build single executable file (.exe file) so that it can be used on other PCs. my source file contains both .c and .cpp files. i have tried to compile/build the program in Release mode but getting errors like:

          fatal error C1853: 'Release\readtxtfile.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

          so i changed the properties of precompiled header from Use Precompiled Header (/Yu) to Create Precompiled Header (/Yc) and now i'm getting errors like:

          error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file

          can anyone help me in this regard. i.e how to make executable file with source file containing both .c and .cpp files. Regards Jawad

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          If all source files are in a single project then change the .c files to .cpp and try building again.

          One of these days I'm going to think of a really clever signature.

          P 1 Reply Last reply
          0
          • L Lost User

            If all source files are in a single project then change the .c files to .cpp and try building again.

            One of these days I'm going to think of a really clever signature.

            P Offline
            P Offline
            pasztorpisti
            wrote on last edited by
            #5

            Legacy source might not compile that way and its constant hassle to upgrade some 3rd parties that come in .c files.

            L 1 Reply Last reply
            0
            • P pasztorpisti

              Legacy source might not compile that way and its constant hassle to upgrade some 3rd parties that come in .c files.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I know, I have been through similar exercises in the past, but sometimes it just needs to be done.

              One of these days I'm going to think of a really clever signature.

              1 Reply Last reply
              0
              • P pasztorpisti

                This precompiled header setting isn't a per-project setting. Set it to "Use Precompiled Header" in the project and inherit this setting in all your .c and .cpp files. After this open the properties windows individually for your stdafx.cpp file and set its precompiled header setting to "Create Precompiled Header". The next step is to select all .c files and open the properties window for them and set the precompiled header setting to "Not Using Precompiled Header". Make sure that you don't include stdafx.h in your .c source files.

                J Offline
                J Offline
                jawadali477
                wrote on last edited by
                #7

                thank you pasztorpisti for your reply. i configured my project to release mode from Configuration Manager and did what you earlier suggested. it builds without errors but when i run exe file, one of the serial ports does not open and gives error 0x7B (system error code). it runs fine (both serial ports open) when build in debug mode. any idea what is happening? Regards Jawad

                P 1 Reply Last reply
                0
                • J jawadali477

                  thank you pasztorpisti for your reply. i configured my project to release mode from Configuration Manager and did what you earlier suggested. it builds without errors but when i run exe file, one of the serial ports does not open and gives error 0x7B (system error code). it runs fine (both serial ports open) when build in debug mode. any idea what is happening? Regards Jawad

                  P Offline
                  P Offline
                  pasztorpisti
                  wrote on last edited by
                  #8

                  That's a bug in your code or one of the libraries you use. :-)

                  J 1 Reply Last reply
                  0
                  • P pasztorpisti

                    That's a bug in your code or one of the libraries you use. :-)

                    J Offline
                    J Offline
                    jawadali477
                    wrote on last edited by
                    #9

                    sorry, i didn't understand. what kind of bug we are talking about? i didn't understand the reason behind this. can you please tell me why this behavior is happening (i.e running fine in debug mode but in release mode, opens one port and not the other)? Regards Jawad

                    P 1 Reply Last reply
                    0
                    • J jawadali477

                      sorry, i didn't understand. what kind of bug we are talking about? i didn't understand the reason behind this. can you please tell me why this behavior is happening (i.e running fine in debug mode but in release mode, opens one port and not the other)? Regards Jawad

                      P Offline
                      P Offline
                      pasztorpisti
                      wrote on last edited by
                      #10

                      There are many reasons for a buggy program to behave differently in debug/release mode. For example code optimization can sometimes screw up your code even if its otherwise non-buggy. Fortunately visual C++ is quite safe in this regard so I wouldnt search for something like this. The most dangerous difference between release builds is memory management/allocation. Debug builds use special values to fill up your stack/heap memory areas when they are allocated to detect programming mistakes (like when you try to use uninitialized variables). This fill doesn't happen when you run your program in release mode resulting in different behavior. Another problem is that even if your build is in Release mode the allocated memory is filled with zeros (not the same value as in debug builds) if you start your executable from your ide by debugging it! For this reason sometimes the bug occurs only if you start the exe from outside your IDE and then attach to it with your debugger. I would search for some uninitialized variables/members...

                      J 1 Reply Last reply
                      0
                      • P pasztorpisti

                        There are many reasons for a buggy program to behave differently in debug/release mode. For example code optimization can sometimes screw up your code even if its otherwise non-buggy. Fortunately visual C++ is quite safe in this regard so I wouldnt search for something like this. The most dangerous difference between release builds is memory management/allocation. Debug builds use special values to fill up your stack/heap memory areas when they are allocated to detect programming mistakes (like when you try to use uninitialized variables). This fill doesn't happen when you run your program in release mode resulting in different behavior. Another problem is that even if your build is in Release mode the allocated memory is filled with zeros (not the same value as in debug builds) if you start your executable from your ide by debugging it! For this reason sometimes the bug occurs only if you start the exe from outside your IDE and then attach to it with your debugger. I would search for some uninitialized variables/members...

                        J Offline
                        J Offline
                        jawadali477
                        wrote on last edited by
                        #11

                        thak you so much pasztorpisti. that was really helpful :-) Regards Jawad

                        1 Reply Last reply
                        0
                        • J jawadali477

                          hi, i have developed program using MFC in vs2008 and now trying to build single executable file (.exe file) so that it can be used on other PCs. my source file contains both .c and .cpp files. i have tried to compile/build the program in Release mode but getting errors like:

                          fatal error C1853: 'Release\readtxtfile.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

                          so i changed the properties of precompiled header from Use Precompiled Header (/Yu) to Create Precompiled Header (/Yc) and now i'm getting errors like:

                          error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file

                          can anyone help me in this regard. i.e how to make executable file with source file containing both .c and .cpp files. Regards Jawad

                          U Offline
                          U Offline
                          User 10355725
                          wrote on last edited by
                          #12

                          Hi i need to show the C++ program in a release version could you help me, how to create an executable file for that. Please let me know if any one could help me. I was trying to make it but few unknow exceptions i couldn’t solve. my id: ksandeepvarma1@gmail.com

                          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