none
Building and compiling Win32 c++ application in VS 2015

    General discussion

  • I'm new at VS, having come from a c++ linux world, so please bear with me for asking stupid questions.

    To get started with W32 development, I've tried a completely basic Visual C++ W32 application - namely the default application which is created when you select New -> Project -> Visual C++ -> Win32 -> Win32 Project, Application type: Windows application, Precompiled header (X), Security Development Licecycle (X).

    As you all know, this creates a basic W32 application with nothing more than a window.

    I can build the solution, by chosing Build -> Build Solution (F6), and it compiles, builds and runs.

    However, if I select Build -> Compile (Ctrl-F7), I get the following error message:

    Error    MSB3644    The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.    Win32    C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets    1098

    Now, since I'm trying to create a Win32 application, I don't understand why it's complaining about .NET?

    Also, where is the output from the build? I can see no executable files in the Workspace\Solutionname\Projectname\ folder?

    Tuesday, November 01, 2016 7:11 PM

All replies

  • However, if I select Build -> Compile (Ctrl-F7), I get the following error message:

    What source file do you have as the active document when you invoke
    that command?

    Also, where is the output from the build?

    By default it's in $(OutDir)$(TargetName)$(TargetExt) - which is
    either under YourProjectRoot\Debug or YourProjectRoot\Release
    depending on which configuration you've built.

    Having said that, the location/naming is all configurable.

    The output window normally shows you where the output is produced.

    Dave

    Tuesday, November 01, 2016 10:24 PM
  • Frank, welcome to the wonderful world of .NET we are all addicted to it around here, and soon it will be your turn.

    In Visual Studio you can build the entire solution or you can build one project only (or more then one project if you select multiple projects on your Solution Explorer Window. them, but lets not complicate things).

    So in short, You can build the solution, or you can build only the selected project(s).

    Now, lets talk about dependencies. When you Build the entire solution Visual Studio will build it in the correct order, from the bottom up. So it will start with the project that has less dependencies to the project that has more dependencies. That is an easy one to grasp, right?

    Now think about this scenario: You are building project B, which depends on ( or "has a reference to" , to use VS lingo) project A. So if you select project B on the Solution Explorer and select Build ( or Compile with C++, looks like) then you will be building a project without building its dependencies. If they were not built before you will have problems.

    In my C# world, as long as you pay attention to what you are building you don't have those issues. Wish I had more knowledge of your C++ world to give you more advice.

    Here is a solid MSDN FORUMS advice: Repost this as a question (not a General Discussion) on the MSDN C++ forum. You will get much better results, faster.


    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.


    Mauricio Feijo
    www.mauriciofeijo.com


    Wednesday, November 02, 2016 12:21 AM
  • >What source file do you have as the active document when you invoke
    >that command?

    Dave:

    The only .cpp file I have so far, which is the one containing the Winmain function.

    Under General in the Project propertis, this is in the output:  $(SolutionDir)$(Configuration)\. It maps to C:\Users\frank\Source\Workspaces\Windows applications\CppWin32App\Release\. However, that folder doesn't exist. Is that the reason? Shouldn't there be a warning in that case?

    I tried this:
    - Changed the output directory for the project to c:\output
    - Built the project, both from the Build menu and from the Solution Explorer, selecting the project and not the solution. I've also tried Build -> Project only in the Build menu.

    The message is allways "build succeeded", but no more info. And the ouput folder is empty.

    Mauricio:

    Thanks :-)

    In this solution, there is only one project, and that's the basic/default Win32 project. No matter if I build the whole solution or just the project, there is no output file(s) anywhere I can find (as specified above in the answer to Dave).

    >Here is a solid MSDN FORUMS advice: Repost this as a question (not a General >Discussion) on the MSDB C++ forum. You will get much better results, faster.

    Will do. Thanks :-)


    • Edited by frankhovin Wednesday, November 02, 2016 9:00 AM
    Wednesday, November 02, 2016 8:19 AM
  • >Under General in the Project propertis, this is in the output:  $(SolutionDir)$(Configuration)\. It maps to C:\Users\frank\Source\Workspaces\Windows applications\CppWin32App\Release\. However, that folder doesn't exist. Is that the reason? Shouldn't there be a warning in that case?

    OK, that defines $(OutDir), also check the Linker, General, Output
    File setting to see what that's using.

    Dave

    Wednesday, November 02, 2016 11:08 AM
  • Linker -> General -> Output:

    $(OutDir)$(TargetName)$(TargetExt) - which maps to the same folder.


    • Edited by frankhovin Wednesday, November 02, 2016 1:45 PM
    Wednesday, November 02, 2016 1:44 PM
  • Linker -> General -> Output:
    $(OutDir)$(TargetName)$(TargetExt) - which maps to the same folder.

    Looks OK, not sure what the issue is.

    Can you reproduce it if you create a new Win32 project with all
    default settings?

    Dave

    Wednesday, November 02, 2016 4:04 PM
  • Yup. A new C++ Win32 project in the same solution, with absolutely no modifications to the default code, yields the same error when trying to compile the .cpp file with the WinMain function.
    Wednesday, November 02, 2016 5:51 PM
  • >Yup. A new C++ Win32 project in the same solution, with absolutely no modifications to the default code, yields the same error when trying to compile the .cpp file with the WinMain function.

    Clearly that should work, there must be something amiss with your VS
    installation.

    I assume you get the same result with a Win32 console project?

    If you get the same result, all I can suggest is that you try
    reinstalling VS.

    Dave

    Wednesday, November 02, 2016 9:09 PM
  • One of the (several) things I don't understand is: How can there be a difference? When I build the application, it also compiles it (naturally), so how can "just compile" be different?

    It's the same with a console project, yes. Also, a completely new solution yields the same crap.

    Reinstalling, sure. It's just that installing it was a time-consuming hassle in the first place :-/


    • Edited by frankhovin Thursday, November 03, 2016 11:56 AM
    Thursday, November 03, 2016 11:55 AM
  • One of the (several) things I don't understand is: How can there be a difference? When I build the application, it also compiles it (naturally), so how can "just compile" be different?

    I don't know.

    Reinstalling, sure. It's just that installing it was a time-consuming hassle in the first place :-/

    You could try starting VS in safemode, or reset its settings to see if
    they have any effect.
    https://msdn.microsoft.com/en-us/library/xee0c8y7.aspx

    Dave

    Thursday, November 03, 2016 2:43 PM