While Patrick is right and I agree that you should use the proper
compiler for the given language, it is not true that your assumption
about filenames was wrong.
The `gcc` command is choosing the compiler for the file based on its
suffixÂ¹. Files ending with â.ccâ are among these considered to be C++
sources and they should compile fine with `gcc`.
Your description confirms that compilation goes ok. What doesnât is
linking. Compiled files have no language â theyâre already compiled â
and therefore `gcc` has no idea that it should do language-specific
magic, like linking against libstdc++.
Â¹ man gcc â the begining of âOptions Controlling the Kind of Outputâ