#VS code for c++
66 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
#include <iostream>
using namespace std;
int main() {
cout << "hello" << end1;
return 0;
}
i found this code in a tutorial video on youtube for setting it up. but when i run it, its not working. it gave this :
error: 'end1' was not declared in this scope
cout << "hello" << end1;
^~~~
That's the second time in two days this has happened. Never seen this mistake before, though 🤣
but i did put the number 1 😭
i checked again
same error
But it's NOT a number 1
oh u meant i have to use the letter ?
got it, one moment
Build finished with error(s).
- The terminal process failed to launch (exit code: -1).
- Terminal will be reused by tasks, press any key to close it.
gave this now.
one other thing, the "cout" line isnt colored for me. whereas in the YT tutorial it was colored
like this
im sorry if my doubts are trivial or stupid, im new to VS and programming
it is possible that you do not have installed the extentions how would do this for you
*who
i installed mingw as well as the c/c++ extensions
"Failed to launch" is a vscode setup thing. Follow a tutorial for setting up for c++. There's one by Microsoft
like i said, it runs c programming properly.
okay
@opaque karma i followed all the steps. in the last bit, the same problem happened again. the cout isnt colored again
like in this
and it gave an error once again
https://code.visualstudio.com/docs/languages/cpp
I used this link
can you please copy and paste the error
static_initialization_and_destruction_0':
c:/mingw/lib/gcc/mingw32/6.3.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::Init()'
collect2.exe: error: ld returned 1 exit status
Build finished with error(s).
- The terminal process failed to launch (exit code: -1).
- Terminal will be reused by tasks, press any key to close it.
#include <iostream>
using namespace std;
int main() {
cout << "hello" << endl;
return 0;
}
code used ^
it seems like that you have maybe not set the correkt include path
how do i do that
not sure how to do that
you use windows?
yea
https://code.visualstudio.com/docs/cpp/config-mingw
in this video on the top in the last minute they will show you how this works
please let my know if it works
thank you ill check it out rn
@toxic stirrup Has your question been resolved? If so, type !solved :)
okay i followed the tutorial, only thing is i had previously installed mingw on my own. nevertheless, i followed whatever was mentioned. but again,the same error popped up
could it be a compiler error?
given that cout wasnt colored.
or should i have saved it in some particular format? ( right now the file name is random.cpp )
it seems that something cannot be found according to your error somethin is wrong in the library that you are using
random.cpp is totally fine
Are you running code on Windows proper or in wsl?
Must be normal windows, right?
It looks you've just not installed something correctly, or perhaps some environment variable (PATH) had not been updated. Have you rebooted since installing compilers etc?
@opaque karma i could need your help too it seems you are a good coder
The top stack overflow thread suggests you may be using gcc to compile, instead use g++
im pretty sure its windows proper
yeah i have. should i do it again since i downloaded stuff after that video above i watched?
how do i like, switch to g++
Dunno. Might be in tasks.json.
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:/MinGW/bin/gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\${fileBasenameNoExtension}.exe",
""
],
@opaque karma ?
should i edit it?
theres more to it, i only sent a part.
Yeah. Google for how to reselect a different task. Idk vscode, but there will be sunbathing to type in the command pallette
You want a g++ option, not gcc
Not sure the command, but you need to reselect this
I mean, from that drop down... Ignore the green box
okay i will check it out
also, my code is running normally and works in the regular output, i just checked it. the terminal thing is the one having problems