Ask Your Question

how to use c++ in fedora?

asked 2014-10-15 20:27:59 +0000

fedora20_user gravatar image

updated 2014-10-15 20:29:38 +0000

I have fedora 20 on my laptop. and C language works without problems, it gets compiled with command [gcc filename.c] but how do I compile it as C++? I just read man gcc and it says I have to save the file with extended name [C, cc, cpp, CPP and some more] but it doesn't work.

And I surely installed gcc-c++ by command sudo yum install gcc-c++

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted

answered 2014-10-15 21:45:06 +0000

g++ file.cpp
edit flag offensive delete link more

answered 2014-10-15 22:02:20 +0000

dnozay gravatar image

yum install gcc-c++ is indeed correct.

If you are missing dependencies, you can check which packages are missing with repoquery:

$ repoquery --requires --resolve gcc-c++

create hello.cpp:

#include <iostream>
using namespace std;

    cout << "Hello World!\n";
    return 0;

then run

$ g++ hello.cpp
$ ./a.out 
Hello World!
edit flag offensive delete link more


gcc-c++ is the correct package. just see the output of "rpm -ql gcc-c++" and you will see "/usr/bin/g++"

pnemade ( 2014-10-17 04:42:05 +0000 )edit

answered 2014-10-15 21:52:03 +0000

deusdara gravatar image


Please see that thread

C++ compiler for fedora 20


edit flag offensive delete link more

answered 2014-10-16 22:56:16 +0000

SantoshHoropter gravatar image

I suggest after installing by

yum install gcc-c++

you can go for codeblocks if you are a beginner/moderate,

yum install codeblocks

Once there, you can be easy on programs because of awesome sweet gui of the software.

Warning : It makes you super lazy (jk!)

edit flag offensive delete link more


I didn't mean to take away terminal experience but for most programming purposes codeblocks is great! If you needed to compile simply try cc <filename.cpp> or g++ <filename.cpp></filename.cpp></filename.cpp>

SantoshHoropter ( 2014-10-16 23:00:12 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.


Asked: 2014-10-15 20:27:59 +0000

Seen: 7,619 times

Last updated: Oct 16 '14