0

Executing task: C/C++: gcc build active file

Starting build...
/usr/bin/gcc -fdiagnostics-color=always -g /home/ashu/Documents/Box/qs.cpp -o /home/ashu/Documents/Box/qs
/usr/bin/ld: /tmp/ccp8ejZt.o: warning: relocation against `_ZSt4cout' in read-only section `.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]'
/usr/bin/ld: /tmp/ccp8ejZt.o: in function `main':
/home/ashu/Documents/Box/qs.cpp:135:(.text+0x68): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:135:(.text+0x70): 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: /home/ashu/Documents/Box/qs.cpp:140:(.text+0x94): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:140:(.text+0x9c): 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: /home/ashu/Documents/Box/qs.cpp:140:(.text+0xac): undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:140:(.text+0xc1): 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: /home/ashu/Documents/Box/qs.cpp:141:(.text+0xf0): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:141:(.text+0xf8): 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: /home/ashu/Documents/Box/qs.cpp:145:(.text+0x11a): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:145:(.text+0x122): 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/ccp8ejZt.o: in function `LinkedList<int>::~LinkedList()':
/home/ashu/Documents/Box/qs.cpp:38:(.text._ZN10LinkedListIiED2Ev[_ZN10LinkedListIiED5Ev]+0x3b): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /tmp/ccp8ejZt.o: in function `LinkedList<int>::insertAtEnd(int)':
/home/ashu/Documents/Box/qs.cpp:45:(.text._ZN10LinkedListIiE11insertAtEndEi[_ZN10LinkedListIiE11insertAtEndEi]+0x1a): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: /tmp/ccp8ejZt.o: in function `LinkedList<int>::insertAtBeginning(int)':
/home/ashu/Documents/Box/qs.cpp:59:(.text._ZN10LinkedListIiE17insertAtBeginningEi[_ZN10LinkedListIiE17insertAtBeginningEi]+0x1a): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: /tmp/ccp8ejZt.o: in function `LinkedList<int>::display()':
/home/ashu/Documents/Box/qs.cpp:112:(.text._ZN10LinkedListIiE7displayEv[_ZN10LinkedListIiE7displayEv]+0x29): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:112:(.text._ZN10LinkedListIiE7displayEv[_ZN10LinkedListIiE7displayEv]+0x31): 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: /home/ashu/Documents/Box/qs.cpp:118:(.text._ZN10LinkedListIiE7displayEv[_ZN10LinkedListIiE7displayEv]+0x4f): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:118:(.text._ZN10LinkedListIiE7displayEv[_ZN10LinkedListIiE7displayEv]+0x57): undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:118:(.text._ZN10LinkedListIiE7displayEv[_ZN10LinkedListIiE7displayEv]+0x6c): 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: /home/ashu/Documents/Box/qs.cpp:121:(.text._ZN10LinkedListIiE7displayEv[_ZN10LinkedListIiE7displayEv]+0x90): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:121:(.text._ZN10LinkedListIiE7displayEv[_ZN10LinkedListIiE7displayEv]+0x98): 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/ccp8ejZt.o: in function `LinkedList<int>::deleteByValue(int)':
/home/ashu/Documents/Box/qs.cpp:67:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x2c): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:67:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x34): 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: /home/ashu/Documents/Box/qs.cpp:75:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x7a): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:76:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x8b): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:76:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x93): 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: /home/ashu/Documents/Box/qs.cpp:76:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0xa3): undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:76:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0xb8): 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: /home/ashu/Documents/Box/qs.cpp:90:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x110): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:90:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x118): 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: /home/ashu/Documents/Box/qs.cpp:90:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x128): undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:90:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x13d): 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: /home/ashu/Documents/Box/qs.cpp:95:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x165): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:96:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x176): undefined reference to `std::cout'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:96:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x17e): 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: /home/ashu/Documents/Box/qs.cpp:96:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x18e): undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: /home/ashu/Documents/Box/qs.cpp:96:(.text._ZN10LinkedListIiE13deleteByValueEi[_ZN10LinkedListIiE13deleteByValueEi]+0x1a3): 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/ccp8ejZt.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
/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. 

I want to run a c++ program in Vs code on Ubuntu linux distro but this Error pop up

2
  • 1
    How is your task configured? Commented Dec 4, 2024 at 8:45
  • 1
    You should use g++ to compile C++ code, not gcc (which is for C code). g++ links against the C++ standard library, where the std:: things are found. Commented Dec 4, 2024 at 9:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.