i'm new to cpp and just moved to classes, but now im stuck here wondering how do i link 2 or more cpp files to make a project(main.cpp - for main, abc.h - for defining class , abc.cpp- for defining methods outside the class). For now i use the command g++ main.cpp abc.cpp -o main
to link all the files but as my project grows larger it will become more tedious to enter all the file names.Some guy here told if i create a project i should be able to compile as usual without compiling manually.So how do i do that in vscode?
Asked
Active
Viewed 545 times
0

default-303
- 361
- 1
- 4
- 15
-
It doesn't seem to be easy (this is why I don't recommend it for beginners), see the [common questions](https://code.visualstudio.com/docs/setup/setup-overview). It seems to depend on what components you have installed. – john Jun 13 '20 at 10:56
-
Vscode has no notion of projects (at least not without extensions). I suggest reading about [make](https://en.wikipedia.org/wiki/Make_(software)) and [cmake](https://en.wikipedia.org/wiki/CMake). – HolyBlackCat Jun 13 '20 at 10:58
2 Answers
0
You should look for the concept of makefile, and especially cmake which will help you for your compilation problem.

Sam Gubline
- 3
- 1
0
For bigger projects you can use makefile for compiling easily and faster. So in vs code I recommend you to use this extension. VS Code C/C++ Makefile Project
Firstly,
C/C++ Make: INIT Project
After,
C++ Project
In makefile you can customize your settings.
Also you can watch this tutorial video to understand easily this process in vs code Debugging Makefile Project with Visual Studio Code

Hasan Basri
- 848
- 8
- 16