Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

What to type at command line after sudo apt-get install...? I want the MinGW compiler like I have on my Windows computer

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

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 libstc++ 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.

share|improve this answer
3  
Why not apt-get install build-essential? –  Steven Devijver Feb 2 '13 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 '13 at 12:48
    
thank you! c++ is so much better than python xD –  imulsion Feb 2 '13 at 16:59
add comment

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.

share|improve this answer
1  
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 at 16:36
add comment

Your Answer

 
discard

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.