[arch-general] 'gcc' vs 'c++' for compiling c++ files

mpan archml-y1vf3axu at mpan.pl
Thu Sep 7 22:13:45 UTC 2017


  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”


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/arch-general/attachments/20170908/8b460dd3/attachment.asc>


More information about the arch-general mailing list