gcc : undefined reference error

A very common compiler error when we try to compile a C++ program using gcc on Linux.

$ gcc new.cc 
/tmp/cccP8Jve.o: In function `main':
new.cc:(.text+0xe): undefined reference to `operator new[](unsigned long)'
new.cc:(.text+0x1c): undefined reference to `std::cout'

Fix :

(a) Use g++ : g++ new.cc

(b) gcc -lstdc++ new.cc

Leave a Reply

Your email address will not be published. Required fields are marked *