If you have a very basic C++ program that only uses the 'cout' object, you can include iostream in the source file and then when you compile it you don't have to link any external libraries. In other words, you can simply run
g++ main.cpp -c
g++ main.o -o program
./program
When you want to use more complicated objects such as threads, not only do you include pthread, but when you link the program you have to link to a library.
g++ main.cpp -c
g++ main.o -lpthread -o program
./program
So my question is, why didn't I have to link any libraries to use all the iostream objects?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With