none
can not add cpp file to project.

    Question

  • hello everyone,

    i added the cpp files and header files to my msvs c++ project with ADD/New Item/. but i can not compile these files under the project. anyone knows why? and how can i add the files to the project so that i can compile those files? thanks a lot!

     

    Tuesday, January 17, 2017 2:38 PM

All replies

  • Please follow these instructions for Adding Files to an Empty Win32 Application.

    If you cannot compile the files, why not?  Is the menu option not available?  Do you get an error?  What is the problem?  Please be specific and descriptive about the symptoms or errors.



    Tuesday, January 17, 2017 3:28 PM
  • Thanks for Wyck’s reply.

    Hi Rui Yin,

    Welcome to the MSDN forum.

    You can have a look at the Wyck’s reply and it describes how to add files to Win32 project and you can also find the information or hyperlinks about the Visual C++ properties and build the program.

    >> but i can not compile these files under the project. anyone knows why?

    Did you get any compile error message? If there has any error or warning information, please share it in here, that will help us to research this issue.

    >>and how can i add the files to the project so that i can compile those files?

    How did you tried to compile the files? Refer to your description, I tried to add the cpp files and header files under a Win32 project like you said, if right click the header file, the option ‘Compile’ is unusable, since it cannot directly compile. For the cpp file, click ‘Compile’, the result is failed and got the following error message:

    If your issue is the same with the above, you can copy the line #include "stdafx.h" into the cpp file ‘source.cpp’ and compile it again, or turn off the pre-compiled headers. Right click the project name and select Properties, in the property pages, go to Configuration properties—C/C++-Precompiled Headers and set ‘Precompiled Header’ to ‘Not Using Precompiled Headers’, please have a look at this similar issue.

    If I have any misunderstand about your issue, please provide the detail information or steps in here, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 18, 2017 5:54 AM
    Moderator