I have the following code:
#include <sstream>
using namespace std;
int
main ()
{
ostringstream oss;
unsigned long k = 5;
oss << k;
}
Compiled with the following parameters:
/usr/local/gcc-10.2.0/bin/g++ -I/usr/local/gcc-10.2.0/include -L/usr/local/gcc-10.2.0/lib64 -Wl,-rpath,/usr/local/gcc-10.2.0/lib64 -lstdc++ b.cpp
Got the following output:
/tmp/cclRSXGV.o: In function
main': b.cpp:(.text+0x35): undefined reference to
std::ostream::operator<<(unsigned long)'
collect2: error: ld returned 1 exit status
What is needed to get it to compile and link correctly?
Using GNU gcc 10.2.0.
g++ -Wall -std=c++11
works for me -- try specifying-std=c++11
– wcochran