franneck94 / Vscode-C-Cpp-Runner

🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀
MIT License
53 stars 14 forks source link

run gcc for both .c and .cpp files #142

Closed FeelUsM closed 9 months ago

FeelUsM commented 9 months ago

When I try to debug .c file - everything OK.
But when I I try to debug .cpp or .cxx file - it calls gcc instead of g++ so I get compile time error:

...
Starting build...
/usr/bin/gcc -fdiagnostics-color=always -g /home/feelus/tmp/hello_cpp/hello.cpp -o /home/feelus/tmp/hello_cpp/hello
/usr/bin/ld: /tmp/ccTMQ3Vo.o: warning: relocation against `_ZSt4cout' in read-only section `.text'
/usr/bin/ld: /tmp/ccTMQ3Vo.o: in function `main':
/home/feelus/tmp/hello_cpp/hello.cpp:3: undefined reference to `std::cout'
/usr/bin/ld: /home/feelus/tmp/hello_cpp/hello.cpp:3: 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*)'
/usr/bin/ld: /tmp/ccTMQ3Vo.o: in function `__static_initialization_and_destruction_0(int, int)':
/usr/include/c++/11/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: /usr/include/c++/11/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: 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. 

How to make this extension to run g++ (instead gcc) for .cpp or .cxx files?

(When I compile hello.cpp with g++ in WSL console - everything OK, but when I compile hello.cpp with gcc in WSL console - I get the same errors.)

franneck94 commented 9 months ago

Your console output that you send is NOT from my extension