English
Ask Your Question
1

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
5

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

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

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++
libmpc-0:1.0.1-2.fc20.i686
gmp-1:5.1.2-2.fc20.i686
mpfr-0:3.1.2-4.fc20.i686
glibc-0:2.18-11.fc20.i686
libstdc++-0:4.8.3-7.fc20.i686
gcc-0:4.8.3-7.fc20.i686
zlib-0:1.2.8-3.fc20.i686
libstdc++-devel-0:4.8.3-7.fc20.i686

create hello.cpp:

#include <iostream>
using namespace std;

main()
{
    cout << "Hello World!\n";
    return 0;
}

then run

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

Comments

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
1

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

deusdara gravatar image

Hi

Please see that thread

C++ compiler for fedora 20

https://ask.fedoraproject.org/en/question/39177/c-compiler-for-fedora-20/

edit flag offensive delete link more
0

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

Comments

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.

Stats

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

Seen: 6,789 times

Last updated: Oct 16 '14