gcc with explicit linking <p>I would like with compile C++ code with GCC using command</p> <pre><code>gcc -lstdc++ hello.cpp -o out.a </code></pre> <p>Code:</p> <pre><code>#include &lt;iostream&gt; int main() { std::cout&lt;&lt;"hello"; return 0; } </code></pre> <p>Got output:</p> <pre><code>/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&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::operator&lt;&lt; &lt;std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, 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$ </code></pre>