C ++的VS代码设置 [英] VS Code setup for C++

查看:110
本文介绍了C ++的VS代码设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在理解如何设置VS Code以创建C ++(11)程序时遇到问题. 我以前安装了VS 2015社区,所以我拥有在一个软件包中创建程序的所有必要条件.现在,我想学习如何在文本编辑器/非完整的IDE中执行相同的操作.

I have a problem with understanding how to setup VS Code to create C++ (11) programs. I had installed previously VS 2015 community, so I had everything necessary to create a program in one package. Now I want to learn how to do the same thing in text editor/not full IDE.

我已经安装了c ++扩展名,创建了新文件夹,并使用hello world创建了简单的main.cpp.我不知道如何告诉VS Code使用Visual C ++编译器和调试器,或使用哪个其他编译器下载设置.我也不知道如何设置json文件来编译和调试Code中的程序. 官方文档并没有告诉我太多,而且我也不知道如何使用CMake之类的工具.

I have installed c++ extension, created new folder and created simple main.cpp with hello world. I don't know how to tell VS Code to use Visual C++ Compiler and Debugger, or which other compiler to download an set up. I also don't know how to set up json files to compile and debug program in Code. Official documentation doesn't tell me much, and I do not know how to use tools like CMake.

我只想学习手动创建,为python设置代码只是安装一个软件包并添加路径变量,然后我要做的就是单击带有集成控制台设置的debug.我猜想python自动化了所有必要的动作.

I just want to learn to create that manually, setting up Code for python was just a matter of instaling a package an adding path variable then all I had to do was to click debug in with integral console setting. I guess python automated all necessary actions.

如何用c ++完成所有这些工作?

How can do all of that for c++?

推荐答案

VSCode只是一个代码编辑器,您必须自己进行编译. Python在解释器上运行,因此您无需编译程序.对于VSCode,您必须保存文件,然后使用编译器将文件编译为可执行文件.编译通常会将.cpp文件编译为机器代码(程序集),然后由链接程序转换为可执行文件.

VSCode is just a code editor, you have to do the compiling by yourself. Python runs on an interpreter, so you don't have to compile the program. For VSCode you have to save the file and then use a compiler to compile the files into an executable. A compile will usually compile the .cpp files into machine code(assembly), which then gets turned into an executable by the linker.

打开终端/命令提示符,或VSCode-> View->集成终端.如果您没有编译器,那么我建议您下载GCC,因为它非常易于使用.在Windows上,您可以使用Cygwin下载它.然后,使用终端/命令提示符,使用您选择的编译器来编译文件.在GCC中看起来像这样

Open terminal/command prompt, or VSCode->View->Integrated terminal. If you don't have a compiler, then I would suggest downloading GCC, because it's fairly easy to use. On Windows you can download it with Cygwin. Using the terminal/command prompt you would then compile your files with the compiler of your choice. In GCC it would look like this

g++ <.cpp files> -o <output file>

这篇关于C ++的VS代码设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆