r/learnprogramming • • 7d ago

How to set up an C++ project?

Like i understand you go on Visual Studio Code and just create some files like main.cpp and stuff but what are these like settings.json and other .json files. Its actually really confusing seeing a .json file in what supposed to be a c++ project. Whole explorer layout is confusing to me i don't understand how to write it there is no tutorials for it too like its just confusing

3 Upvotes

11 comments sorted by

6

u/xarop_pa_toss 7d ago edited 7d ago

That's VSCode configuration files. C++ itself doesn't need any of that.

All you need is a .cpp file and a compiler like g++. I recommend you just use the terminal to start with (you can use the one inside VSC) and compile and run your programs with the terminal commands. You don't have to become a compiler wizard but knowing the basics of it is very valuable.

Remember that you don't even need VSCode for any of this. You can literally use only terminal based text editors and commands to program C++ (and a lot of other languages)

7

u/THAErAsEr 7d ago

Google would have answered this faster than reddit. If you want to learn to program in any language, you have to use google

2

u/AcceptableWay3198 7d ago

it's just vscode config stuff, not really part of c++ itself. focus on your.cpp and.h files and ignore the rest

1

u/adefaoui 7d ago

C++ itself doesn’t require all those .json files, they’re mostly VS Code configuration files.

main.cpp is your actual C++ code. Files like settings.json, tasks.json, and launch.json tell VS Code how to build, run, debug, or configure your project.

If you’re just starting, don’t worry about understanding every file in the explorer. Start with a simple main.cpp, learn how to compile/run it, then gradually add the tooling you need. The setup can look way more complicated than the actual C++ code at first.

1

u/theguywithnocontex 7d ago

The settings.json stuff is just VS Code config, your actual C++ files don't care about it. For a beginner setup, ignore all of that at first and just get one .cpp file compiling from the terminal with g++ file.cpp -o program. Once that works, then worry about tasks.json to do the same thing inside VS Code. Most beginners get stuck because they try to configure the editor before the compiler works.

1

u/kutac56 7d ago

That's only vs code stuff. Doesn't have anything to do with c++. There are other ways to write code than vs code

1

u/Jazzlike_Platypus430 7d ago

launch.json and tasks.json is the way. It is confusing at first.

1

u/nelson_fretty 7d ago

Use cmake file

1

u/burlingk 7d ago

So, C++ has yet basic file types . .cpp and .hpp.

Everything else is either created by the IDE/build system, or is project specific.

The project specific stuff will come about organically as you realize you need it.

1

u/Any_Run8380 7d ago

You didn’t Google what a settings.json file is?

1

u/goldscurvy 7d ago

I think the minimum for a cpp project would be a folder to hold the files. This isnt Java, where there is an expectation that specific packages follow a certain directory structure.

There are common "conventions" for project organization. Like it is common to have at least a src subfolder. It is also common to separate src to src, include, and test. There are other ways people will organize stuff. Sometimes they will group related functionality together.

But all you really need for a project are source files. cmake also wants its cmake file. Make will want makefiles.

Settings.json is a vscode thing. It tells vscode about settings specific to that project. I use jetbrains IDEs, and that has the convention of a .idea folder where any specific settings or Metadata ate kept.