Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ linker , how to link the iostream file?

I have a file named main.cpp which includes iostream.

I compiled main.cpp and it worked without errors, so my question is: I compiled main.cpp and I did not link iostream with main.cpp, so how could this be possible? Or did the compiler linked the iostream automatically?

like image 966
AlexDan Avatar asked Feb 15 '12 13:02

AlexDan


1 Answers

The functions in iostream are part of the C++ standard library, which you usually don't need to link explicitly.

If you use a compiler that's not strictly a C++ compiler, you sometimes need to add something like -lstdc++ (at least, I do if I use gcc rather than g++).

like image 167
James McLaughlin Avatar answered Oct 16 '22 05:10

James McLaughlin