none
How to add existing C/C++ console application as a new VS2015 project.

    Question

  • Hi, I have an C/C++ console application that I currently build using CL.EXE, both release and debug versions.  It compile, links and runs fine with simple switches such as:

    cl ShowSmtpStats.cpp /W3 /EHsc /D "_CRT_SECURE_NO_WARNINGS"

    I would like to add this CPP file to an IDE solution as a new project.    I tried to do this by creating a new empty C++ project and I dropped in the CPP file via Solution Explorer.  It compiles an EXE having AfxWinMain( setup requirements so it aborts.

    How can I have a pure C/C++ file compiled to exe project file?    This is basically an issue if getting the right options in the IDE project properties.  I tried everything I could think of with the options.   Somehow the linker seems to think its needs AfxWinMain() and all that stuff in the main code.

    Thanks 


    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com



    Monday, May 2, 2016 7:52 PM

Answers

  • Hi,

    I mostly select the C++ Console project template as starting point:

    And take the standard settings in the wizard (You can deselect precompied header if you don't need this feature):

    Then you get a project with a standard "main" (no AfxWinMain) function:

    Regards,

    David

    Monday, May 2, 2016 8:38 PM

All replies

  • Hi,

    I mostly select the C++ Console project template as starting point:

    And take the standard settings in the wizard (You can deselect precompied header if you don't need this feature):

    Then you get a project with a standard "main" (no AfxWinMain) function:

    Regards,

    David

    Monday, May 2, 2016 8:38 PM
  • Yes, I did exactly this.... and variations too before posting.  I selected an empty console project and then added the existing *.CPP file to it.  I also turned off the security stuff.    I did a clean redo and it working now.   Odd.  Thanks. :)

    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Monday, May 2, 2016 9:11 PM
  • Thanks for David's help for this issue.

    Hi Hector Santos,

    Since this issue has been resolved, would you please mark the helpful reply as the answer? So it would help other members who get the same issue as yours, and I could close this case for you.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 3, 2016 4:13 AM
    Moderator
  • Hi, I would say this is the answer but I am not totally sure because I had already done all this before posting here.

    The IDE produced an AfxWinMain() setup/load requirement.  But not the command line CL compile.   Whatever happen to clear it up, restarting the IDE perhaps, finally did what was expected of creating an empty C++ console project and add the stand alone console *.CPP file to the source folder.   That includes manually going thru all the configuration settings, setting/resetting all options and defines, libs for console compiles.

    So sure, I'll make it the answer but there might be a "bug" in the IDE and/or template or whatever.  In this VS2010 to VS2015 porting project, I've seen another similar situation where I had to delete converted projects which I globally changed some configuration properties, i.e, paths, defines, switches, etc, within the IDE and redo the project conversions but this time not do the global changes to the projects, but instead fix it one by one.

    :)


    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Wednesday, May 4, 2016 3:26 AM