Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanna compile a C++ program in Arch Linux, but there's no "g++" package as there is in Ubuntu repositories for example.

Using -x too won't work. like this:

gcc -x c++ -o myprog myprog.cpp
share|improve this question
up vote 4 down vote accepted

gcc is both a C and C++ compiler.
It will look at the file's extension and process accordingly.
g++ is only a wrapper that calls gcc
g++ is installed with the gcc package in Arch

gcc file.C # uppercase .C (or .cpp) will process as C++ 
gcc file.c # lowercase .c will process as C
share|improve this answer
Though I have gcc on my Arch, there's no g++, and though my file is prog.cpp and I also use -x c++ I should tell you it only works in case I also add -lstdc++, which correctly compiles. Do you suggest this method? (gcc -x c++ -o myprog -lstdc++ myprog.cpp) – Haix64 Mar 21 '12 at 12:19
if you use std c++ in your code then yes, you need to link (-lstdc++) with the std c++ library. I've installed gcc on my arch and g++ is present. It should be in /usr/bin, I don't believe the -x c++ is needed if file extension is .cpp, gcc should select on that – bsd Mar 21 '12 at 13:13
g++ should be part of the gcc package. Have you tried reinstalling gcc? – Craig Mar 21 '12 at 16:56
g++ is part of the gcc package – bsd Mar 21 '12 at 20:09
You gotta be right Craig. I had not installed the gcc manually, since I thought having access to gcc should mean that I've got the whole package on system, but pacman shows me there's 18MB to download for the gcc package. I haven't done it yet but I'm sure it works as soon as I do it. Thanks for your helps, Craig and bdowning. – Haix64 Mar 23 '12 at 14:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.