问题描述
我是Visual Studio的新手,我不知道如何编译.cpp文件。我只做了一个.cpp文件(ctr + n => Visual C ++ => C ++文件),我试图编译它。但是在正常的地方有一个编译按钮(像c#)有奇怪的附加按钮。我不知道发生了什么,但我想,Visual C ++可能是一些不同版本的正常C ++。如果是这样可以在Visual Studio中编译正常的C ++文件?
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?
推荐答案
问题是,Visual Studio真的不知道,怎么处理你的.cpp文件。是一个程序?请尝试以下操作:
The problem is, Visual Studio don't really know, what to do with your .cpp file. Is it a program? Try the following:
-
文件
|新项目
-
Visual C ++
|Win32
|Win32 Project
- 选择项目的名称和位置
-
- 选择
控制台应用
- 选择
清空项目
- 取消选择
预编译头
- 完成
- 右键单击
源文件
选择添加
|新项目...
- 选择
C ++档案
- 为此文件选择名称
-
在其中写入以下内容:
File
|New project
Visual C++
|Win32
|Win32 Project
- Select a name and location for the project
- Next
- Choose
Console application
- Choose
Empty project
- Deselect
Precompiled header
- (optionally) Deselect
SDL checks
- Finish
- Right-click on
Source files
and chooseAdd
|New Item...
- Choose
C++ File
- Choose name for this file
Write the following inside:
#include <stdio.h>
int main(int argc, char * argv[])
{
printf("Hello, world!\n");
return 0;
}
按F5
Press F5
这篇关于如何在visual studio中编译c ++文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!