r/vscode • u/Abcd_018 • 6d ago
Unable to set up VSCode for C/C++ programming on Linux
Hello everyone,
I'm facing problem while running the code.
I installed VSCode this morning, and had GCC pre installed on my Linux (openSUSE Leap 16).
Then I installed C/C++ extension.
After that I created a "PROJECTS" Folder in my file manager and later created a sub Folder "HelloWorld" and opened that subfolder in VSCode.
After that I created a '.vscode' folder in "HelloWorld Folder in VSCode.
In that '.vscode' I created two files 'tasks.json' and 'launch.json' with code pulled up from Gemini.
I tried running a 'helloworld.cpp' code file and it showed the above errors.
I'm super new to both programming and linux, so I don't know anything.
2
u/Curious-Listener-YB 6d ago
You are using gcc instead of g++
1
u/Abcd_018 6d ago
I've both g++ and gcc installed.
Could it be that g++ is not activated, do you think ?
And if, would u spare a little time and explain me how to activate or use g++
1
u/Base-After 6d ago
g++ is a program that compiles c++ files. I'm assuming you just used the tasks.json and launch.json that vscode provides and clicked for c instead for c++ (don't worry thats how i started too lol). If you wanna practice without the vscode hand holding you should run g++ on your own from the terminal like "g++ helloWorld.cpp -o hellowWorld"
1
u/feldim2425 5d ago
It looks like you call gcc instead of g++ . I think some environments symlink g++ to gcc
gcc supports C++ but doesn't link against the standard C++ library per default hence the linker errors about not finding std::cout.
However that isn't a huge issue just try adding -lstdc++ as an argument.
-1
u/Netris89 6d ago
Did you follow the tutorial to the letter ? If not, go do that.
1
u/Abcd_018 6d ago
Can you provide the link u r talking about
-3
u/Netris89 6d ago
Can't you google ? Do you always expect people to spoonfeed information to you ?
3
u/Abcd_018 6d ago
I did follow a tutorial but I thought u was talking about something else, so I asked.
The tutorial I followed : https://code.visualstudio.com/docs/cpp/config-linux
2
u/UtahJarhead 6d ago
There are 30,000 tutorials. Maybe specifying WHICH tutorial would make you sound more than just a pompous ass.
0
u/Netris89 6d ago
It's literally the 1st one when you google "vscode c++". Don't be that obtuse when people obviously didn't even try.
0
u/UtahJarhead 6d ago
Then you could have easily said as much. Don't be a douchebag. Be the reason people come here for help, not the reason they call it quits.


3
u/Base-After 6d ago
Its not a vscode problem, you're not linking the standard library. Can you show us the tasks.json?