10

Is there a well-known package I should install for C++ Development Tools?

What do I type at the command-line after sudo apt-get install?

Ideally, I want the same tools that were installed with "MinGW" on my Windows computer.

3 Answers 3

10

That may depend on your distro, but if you are using raspbian, the stock gcc includes g++, here's the version info:

me@RPi» gcc -v
Using built-in specs.
[...]
--enable-languages=c,c++,fortran,objc,obj-c++ 

So apt-get install gcc should work if it isn't already there.

Most distros will build gcc with C++ support, so this should be true for them too. The easy way to check is to install gcc then try g++ -v.

FYI, GCC is the "Gnu Compiler Collection" used by MinGW; gcc is the C compiler, g++ is C++.

To compile C++ code you'll also need the stdc++ header files (#includes) from the "libstdc++ dev package". There is more than one available for raspbian because there are 4 slightly different versions of libstdc++ available. The one which appears to be the default against which (presumably) all or most binaries in the distro are built looks to me to be 6-4.6. Check with:

dpkg -l | grep ++

That's what is currently installed. If you don't see any libstdc++ listed, then just pick one from what's available (apt-cache search libstdc++). You can have them all installed at the same time, although the system will tend to use only one (there is a symlink based on major version in /lib to one of the .so's). So:

apt-get install libstdc++6-4.6-dev

That should (I think) include the base library as a prereq, in which case that and gcc and its prereqs should cover everything. If it doesn't, just install libstdc++6-4.6. Library packages in most linux distros come in two parts, the runtime, and the headers in a separate -dev package for compiling using the API.

2
  • 7
    Why not apt-get install build-essential? Feb 2, 2013 at 8:04
  • 1
    Sure; I'm presuming that's a metapackage and I've never bothered with them but I sure they are handy. Getting a basic C/C++ environment doesn't require much beyond what will be prereqs for gcc anyway. The stdc++ dev headers -- I'll add a note.
    – goldilocks
    Feb 2, 2013 at 12:48
13

To install development tools on raspbian :

sudo apt-get install build-essential
2
  • Which does indeed include g++.
    – goldilocks
    Nov 17, 2015 at 18:48
  • This should probably be the accepted answer. Someone who does not know how to install a compiler probably does not know how to install the other other common developer tools. They just want to run pip install <package> (or whatever those Python package managers do) and expect things to just work.
    – user50099
    Jul 18, 2019 at 5:16
0

best app for C++ can be found by either searching Code Blocks of going on apps and looking down till you see it and its actually quite near the top. I used this app on my PC before i discovered it on my raspberry pi and has syntax highlighting and everything.

1
  • 3
    Hi Luke. Note that Code::Blocks is an IDE and not a compiler. It is compatible with gcc (which is the native linux compiler) and the windows visual C++ compiler.
    – goldilocks
    Mar 17, 2014 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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