Reputation: 806
I am new to Visual Studio and I don't know how to compile a .cpp file. I made just a single .cpp file (ctr + n => Visual C++ => C++ file) and I tried to compile it. But in place where normally there's a compile button (like with c#) there is strange 'Attach' button. I don't get what's going on, but I thought, Visual C++ might be some different version of normal C++. If so is that possible to compile normal C++ file in Visual Studio?
Upvotes: 9
Views: 72668
Reputation: 25927
The problem is, Visual Studio don't really know, what to do with your .cpp file. Is it a program? Try the following:
File
| New project
Visual C++
| Win32
| Win32 Project
Console application
Empty project
Precompiled header
SDL checks
Source files
and choose Add
| New Item...
C++ File
Write the following inside:
#include <stdio.h>
int main(int argc, char * argv[])
{
printf("Hello, world!\n");
return 0;
}
Press F5
Upvotes: 14
Reputation: 76519
You should, just as you did for C#, create a C++ project and add your source file to that. Then there will be all the build options you ever dreamed of.
Upvotes: 2