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.

imulsion
  • 751
  • 4
  • 10
  • 19

3 Answers3

13

To install development tools on raspbian :

sudo apt-get install build-essential
mpromonet
  • 1,124
  • 18
  • 37
Henry Todd
  • 151
  • 1
  • 3
  • Which does indeed include g++. – goldilocks Nov 17 '15 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. –  Jul 18 '19 at 05:16
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.

Bex
  • 2,929
  • 3
  • 25
  • 34
goldilocks
  • 58,859
  • 17
  • 112
  • 227
  • 7
    Why not apt-get install build-essential? – Steven Devijver Feb 02 '13 at 08: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 02 '13 at 12:48
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.

  • 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 '14 at 16:36