Tools - code + vs + cmake + c/c++
Purpose
In the development process, use VSCODE instead of VS.
In view of my own development language C/C++/python
, the development platform spans Linux
and win
, the commonly used tools are cmake
, and considering that my computer configuration is not very high, so choosing a lightweight development tool is conducive to efficient work.
VS
As the strongest IDE
title in the universe, it is difficult to shake, but code
the advantages are also very obvious:
- Lightweight, it only takes a few seconds to turn on my computer
code
, and itvs
takes 20+ seconds to turn it on; - File management is convenient, which
code
is closely related to the positioning as a file editor; - Cross-platform, although the learning cost is high under a single system, but considering the cross-platform attributes, it reduces the learning cost;
Of course, code
the flaws are also obvious:
- Configuration is troublesome, various configurations; (this article is to record how to solve these problems)
- Code prompt, not sensitive, sometimes unable to prompt
1. Introduction
Development platform:
System : win + wsl
Development language : c/c++
Configuration tool : cmake
Compiler : vs2019
Basic document introduction
Introduction to commonly used files on the official website:
tasks.json (build instructions)
launch.json (debugger settings)
c_cpp_properties.json (compiler path and IntelliSense settings)
1.1 Plugins
Required plugins: C/C++
and CMake
the
1.2 configuration
1.2.1 Basic version – the lowest method
To use, first use the shortcut key Ctrl + Shift + P
, and then follow the steps below:
CMake: Select a Kit
: Select the compiler, it can beMSVC, WinGW, gcc, g++
etc. In principle, it will automatically scan the compiler on the computer, but it does not rule out the need to set it manually (I haven’t learned how to set it yet);CMake: Select a Variant
: choose to beRelease
orDebug
wait, the default isDebug
;CMake:Configure
build
: cmake configuration environment, a folder created in the current directory by default ;CMake: Build
compile;
ps:下一步目标,把所有默认改成便于修改项
1.2.2 Advanced – Configuring Tasks.json
I will add it later if there is a need, but I haven't found it useful for the time being
CUDA
In CMakeLists.txt
modified project
to:
project(main LANGUAGES CXX CUDA)