When i launch my c++ program with the terminal of the IDE visual studio code i get an error message that i can't solve:
C++ program:
#include <iostream>
using namespace std;
class Afficher{
public:
Afficher(int);
~Afficher();
};
main(int argc,char** argv){
Afficher yolo(10);
};
Afficher::Afficher(int a){
char ch = a;
cout << a << endl;
cout << "\n\n constructeur" << endl;
//printf("constructeur\n\n");
};
Afficher::~Afficher(){
cout << "desstructeur \n\n" << endl;
}
visual studio code terminal error:
Starting build...
C:\MinGW\bin\gcc.exe -fdiagnostics-color=always -g C:\Users\mathi\OneDrive\Bureau\DOC\ISTY\C++\C++ERWAN\exo2.cpp -o C:\Users\mathi\OneDrive\Bureau\DOC\ISTY\C++\C++ERWAN\exo2.exe
C:\Users\mathi\AppData\Local\Temp\cc1bTbUb.o: In function `ZN8AfficherC2Ei':
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:20: undefined reference to `std::cout'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:20: undefined reference to `std::ostream::operator<<(int)'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:20: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:20: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:21: undefined reference to `std::cout'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:21: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:21: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:21: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:\Users\mathi\AppData\Local\Temp\cc1bTbUb.o: In function `ZN8AfficherD2Ev':
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:28: undefined reference to `std::cout'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:28: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:28: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
C:/Users/mathi/OneDrive/Bureau/DOC/ISTY/C++/C++ERWAN/exo2.cpp:28: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:\Users\mathi\AppData\Local\Temp\cc1bTbUb.o: In function `_tcf_0':
c:/mingw/lib/gcc/mingw32/6.3.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
C:\Users\mathi\AppData\Local\Temp\cc1bTbUb.o: In function `_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()'
C:\Users\mathi\AppData\Local\Temp\cc1bTbUb.o:exo2.cpp:(.eh_frame+0x77): undefined reference to `__gxx_personality_v0'
collect2.exe: error: ld returned 1 exit status
Build finished with error(s).
* The terminal process terminated with exit code: -1.
* Terminal will be reused by tasks, press any key to close it.
Is there an easy way to solve that?
I want to solve that problem for let me launch the program in the active windows of my IDE visual studio code with just 1 touch F5.
(when i work on C++, to start my program with the shortcut F5. same with python with the shortcut F5, when i work en python)