I would like with compile C++ code with GCC using command
gcc -lstdc++ hello.cpp -o out.a
Code:
#include <iostream>
int main()
{
std::cout<<"hello";
return 0;
}
Got output:
/tmp/ccgtX1Xs.o: In function `main':
hello.cpp:(.text+0xa): undefined reference to `std::cout'
hello.cpp:(.text+0xf): 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*)'
/tmp/ccgtX1Xs.o: In function `__static_initialization_and_destruction_0(int, int)':
hello.cpp:(.text+0x3d): undefined reference to `std::ios_base::Init::Init()'
hello.cpp:(.text+0x4c): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
g@GME5420:~/cpp$