PDA

View Full Version : OT: Need A User Friendly C++ Compiler



Paul Alciatore
07-24-2014, 04:01 AM
Calling the computer types here. I am working on an electronic project where I need to learn the C++ computer language. I have found a nice editor for writing the code and purchased a "... for Dummies" book on C++, but still need a compiler to translate the code to executable files.

Can anybody recommend an easy to install and use C++ compiler. There seem to be a lot of choices out there. Preferably a free one, but I will consider a moderate price if it is justified.

adnbr
07-24-2014, 04:23 AM
Is the code for use in the electronics project, say on a microcontroller? That might determine which compiler you use.

In the mean time check out http://gcc.gnu.org/ and http://www.mingw.org/ if you want to compile for a PC. In my experience they are pretty much the go to and don't take much going to get setup.

As for a user friendly compiler... well...

You might find that your editor will have shortcut functionality to allow you to compile and run from within the editor.

MrFluffy
07-24-2014, 05:08 AM
+1 for gcc, it will call the appropriate backend if your source file has a postfix of .cpp. Gcc is really just a front end for a lot of different compiler types that come bundled in by default, and a .cpp will invoke the g++ backend so you get it compiled as c++ and it will be linked against libstdc++ by default.

It can also cross compile to different architectures (I use it to cc to arm on my x86 based machines and the other odd platform from time to time), and often the people who supply the toolchains use it for this reason. I have a friend who does a lot of embedded stuff and he uses it extensively. I could ask him if you have any specific targets in mind if there's anything better for that arch.

EVguru
07-24-2014, 05:24 AM
We are basing a new glasshouse controller design on the Raspberry Pi and my boss is using Geany as the IDE on his PC and cross-compiling to C on the Pi with GCC.

The Artful Bodger
07-24-2014, 06:35 AM
Paul A, can we have more information about what equipment you are developing the code for?

lwalker
07-24-2014, 06:41 AM
For friendliest, I would suggest the free Microsoft Visual Studio (http://www.visualstudio.com/downloads/download-visual-studio-vs#DownloadFamilies_4) products. I linked to the 2010 version because the 2013 versions require at least Windows 7 which you may not have. I use the Professional Enterprise version of these tools at work, and for beginner/intermediate work, the Express versions are fine. I've used them for home projects for years. The VS IDE (Integrated Development Environment) is probably the best one out there and I'm always amazed that Microsoft gives all this stuff away for free.

Others have mentioned gnu g++. It's also very good, but unless you're running Linux or programming microcontrollers (in which case it can't be beat), I'd stick with Visual Studio. If you are going the microcontroller route, then I'd recommend Atmel Studio 6 (http://www.atmel.com/microsite/atmel_studio6/compiler_editor.aspx). It's free, this version is based on Visual Studio so you get a standard look and feel, it comes with g++ and it works great. For small projects Studio 4 is fine. It's very different, but loads faster and requires fewer system resources.

Hope that helps

Lyndon

Jon Heron
07-24-2014, 07:24 AM
Qt is the only way to go in my opinion. Especially if your just getting into c++. It has an excellent IDE with great built in help and examples also. It makes cross platform UI's manageable too.
It is the best cross platform framework out there in my opinion.
Do yourself a favour and download it to check it out.
http://qt-project.org/downloads
Good luck,
Jon

schor
07-24-2014, 08:10 AM
What platform are you on? windows, linux, mac? I would go for gcc since its free. I assume this code you need to write is just plain C code and not full on c++, if so get yourself a kernighan&ritchie 'the C programming language'

Jaakko Fagerlund
07-24-2014, 08:40 AM
Qt gets another vote from here. If you just need a compiler, then g++ is the way to go.

fjk
07-24-2014, 12:19 PM
What are you programming for (OS &processor type) and writing your code on?

Generally gnu compilers would be your best bet, it runs on the most platforms and can be built to generate code for the most.
Alternatively CLANG has been getting a lot of good reviews.

danlb
07-24-2014, 12:36 PM
When you ask for a user friendly compiler, you are really asking for a user friendly program that integrates the editor, debugger, the file management and the compiler. This is commonly known as an IDE (integrated development environment). Each OS has one or more IDE that works well enough.

Other than that, I'm no help at all. I'm an old Unix programmer, so I use VI as an editor and whatever compiler runs on the platform that I'm using. Most often that is g++ ( GNU's C++ variant) and GNU's debugger.

Dan

lwalker
07-24-2014, 01:40 PM
When you ask for a user friendly compiler, you are really asking for a user friendly program that integrates the editor, debugger, the file management and the compiler. This is commonly known as an IDE (integrated development environment). Each OS has one or more IDE that works well enough.

Other than that, I'm no help at all. I'm an old Unix programmer, so I use VI as an editor and whatever compiler runs on the platform that I'm using. Most often that is g++ ( GNU's C++ variant) and GNU's debugger.

Dan

Exactly correct. There's a wide range of personal choice as can be seen from the responses, but for ease of use, Microsoft wins. There's a lot to be said for the open source compilers (and I use them for my Web/Linux and microcontroller work), but then you get into messing with makefiles, what editor to use, what debugger, etc. Whereas helloworld.c is as easy as opening Visual Studio, writing 3 lines of code and clicking the Run icon.

Jaakko Fagerlund
07-24-2014, 03:46 PM
Exactly correct. There's a wide range of personal choice as can be seen from the responses, but for ease of use, Microsoft wins. There's a lot to be said for the open source compilers (and I use them for my Web/Linux and microcontroller work), but then you get into messing with makefiles, what editor to use, what debugger, etc. Whereas helloworld.c is as easy as opening Visual Studio, writing 3 lines of code and clicking the Run icon.
..which is just as easy with Qt, which runs on any platform.

Paul Alciatore
07-24-2014, 08:54 PM
I first just want to learn something about C++ in general. Then I need to do some programming on one or more of the micro controllers with it. Now, I need a general purpose compiler so I can learn. When I start with the micro controllers I will probably use the software recommended by each of them. Fun and games!




Is the code for use in the electronics project, say on a microcontroller? That might determine which compiler you use.

In the mean time check out http://gcc.gnu.org/ and http://www.mingw.org/ if you want to compile for a PC. In my experience they are pretty much the go to and don't take much going to get setup.

As for a user friendly compiler... well...

You might find that your editor will have shortcut functionality to allow you to compile and run from within the editor.

Paul Alciatore
07-24-2014, 09:02 PM
I want to develop code for a variety of micro controllers (PICs) to drive/control a device that I am developing. So far I have successfully written code for the PICAXE controllers in their form of Basic. A number of languages will be involved so I am embarking on a noble quest. C and C style languages are used in many places so I want a basic understanding first. I need to get comfortable with it.

I do not want to publicly discuss that device at this time.



Paul A, can we have more information about what equipment you are developing the code for?

PStechPaul
07-24-2014, 10:48 PM
I think my full version of C compiler for my MIcrochip PIC projects is now actually Hi-Tech C. It seems to have good ratings:
http://www.microchipc.com/reviews/Hi-Tech_C/

You probably do not want to jump directly into C++, which is tailored to object-based programming as is needed for Windows GUIs. First, get a fairly solid mastery of good old K&R "C". I have tried to use C++ and I did not have much success. I found the Borland Delphi IDE with compiler, linker, and debugger was much easier for me. But that does not work for PIC code.

The source code for C is quite portable, as in being capable use on multiple platforms, although there are some hardware-specific functions.

If you decide to use Microchip products, you can download their free package, which is mostly MPLABX, and it also comes with (or maybe a separate download) a version of the Hi-Tech C compilr/linker suite. You will also get many demo projects that are ready to compile and run in the software simulator. You can choose the PIC you want to use and actually develop and run the code before you have the hardware. And there is an excellent forum where you can ask questions and get expert help.

http://www.microchip.com/forums/Default.aspx?

For generally learning how to program using C, there are many free on-line tutorials where you can enter code and then run it to see the results immediately:
http://www.learn-c.org/

Those suggestions are based on my own needs, experience, and preferences. Your needs may be quite different, but these should be a good starting point.

lakeside53
07-24-2014, 10:55 PM
Another vote for QT. It's free and a complete development environment. Sure, you think you just want a complier, but at some point you'll need to debug, "link" (showing my age here), make, and a host of other related tasks.

Download it, and try.

I agree with Paul. C++ is way more complicated than generic "C". With C you'll be up and running a short order; a LOT longer for C++. I wrote a heck of a lot of embedded C in my past. I jumped back in a year ago and it all came back in days. I can stumble though writing my own C++, but the convoluted ways it can be expressed make reading and editing others code difficult at best.

Paul Alciatore
07-24-2014, 11:34 PM
Well, it appears that this thread and request may have been a bit premature on my part. The next chapter in the Dummies book I am following just took me through the download and installation of the Code::Blocks environment which is supposed to include both editor and compiler and probably a lot more. Anyway, I am at that point now. It is installed and my next action is to write my first program.

C, C++, ??? I don't know just how far into C++ that "C++ For Dummies" goes but I may quit before the end. I just need a basic understanding for now.

Onward and upward!

And thanks to all. I found some real gems in the responses.

mickeyf
07-24-2014, 11:39 PM
Another vote here for plain old C if you are working with PICs rather than, say a Windows desktop application. There are many who love (or say they love) C++, but there are at least as many who refer to "That bloated obscenity that is C++".

Especially when programming "down on the bare metal", it is not at all appropriate. A language like C++ can be helpful when developing a large, complex application with complex data structures. For bit twiddling, reading inputs, and toggling outputs, it just gets in the way.

Especially if this is intended largely as a learning experience, get a solid understanding of C before even thinking about C++. Otherwise it may turn you off programming forever.

schor
07-25-2014, 12:45 AM
If you want to learn the basics, get "The C programming language" http://www.amazon.ca/C-Programming-Language-2nd-Edition/dp/0131103628

Your building for microcontrollers so use C not C++. There are far too many pitfalls that can become memory and performance problems if your not an expert c++ programmer.

What's your programming experience? Do you have some knowledge of programming? Writing code for devices is a whole other level, but lots depends on the libraries provided (if any) for the hardware your programming.

Just an opinion from someone that's been writing C and C++ for 25+ years, writing microcode, systems and application software in many languages for that last 38 years.





Well, it appears that this thread and request may have been a bit premature on my part. The next chapter in the Dummies book I am following just took me through the download and installation of the Code::Blocks environment which is supposed to include both editor and compiler and probably a lot more. Anyway, I am at that point now. It is installed and my next action is to write my first program.

C, C++, ??? I don't know just how far into C++ that "C++ For Dummies" goes but I may quit before the end. I just need a basic understanding for now.

Onward and upward!

And thanks to all. I found some real gems in the responses.

Paul Alciatore
07-25-2014, 03:51 AM
My experience with programming? Well, there was Fortran 2 (1960s). And assembly. And good old Basic, many different forms. More assembly. Oh, and real machine language, 0s and 1s (no cheating with hexadecimal) set with a real front panel with 16 switches and some push buttons, one 16 bit word at a time.

Always in small increments. Never as a full time occupation. I am not afraid of C, with or without the "++" I just have to learn it and, as I said, get comfortable with it. I will keep all of the above in mind. Thanks again.

MrSleepy
07-25-2014, 04:21 AM
If you want a C compiler for Pics...go to Microchip.

A few years ago they bought Hi-Tech and developed the XC compiler range to blend seemlessly with the latest MPLab ide.

They work in a "free" mode (which does not use code and memory optimisation) .

Rob

lwalker
07-25-2014, 09:48 AM
Threads have a life of their own, don't they?

For learning C & C++, I'll recommend the same book I've been recommending for the last 16 years, the excellent primer (http://www.amazon.com/The-Complete-Reference-4th-Edition/dp/0072226803) by Herb Schildt. The best book, hands down, on C/C++ I've ever read. Although it calls itself a "reference" it's really an excellent tutorial on both languages.

I would recommend you stick to C for a while. C++ is complex enough. C++ for embedded systems requires experience using C++ on desktops/servers to understand what techniques can get you into trouble.

Bruce Eckel's _Thinking in C++_ is also an excellent book, but the Herb Schildt one covers both C and C++ and does a great job on both. Very well worth the $39.95 IMHO (price was about $19.95 when I bought mine).


Well, it appears that this thread and request may have been a bit premature on my part. The next chapter in the Dummies book I am following just took me through the download and installation of the Code::Blocks environment which is supposed to include both editor and compiler and probably a lot more. Anyway, I am at that point now. It is installed and my next action is to write my first program.

C, C++, ??? I don't know just how far into C++ that "C++ For Dummies" goes but I may quit before the end. I just need a basic understanding for now.

Onward and upward!

And thanks to all. I found some real gems in the responses.

schor
07-25-2014, 10:22 AM
Ok then you should have no problem coding in C with your experience.

I've had to code up a bootstrap loader from the front panel, 8 toggle switches, for an old cpm machine when the bootstrap rom died, that was back in the early 80's, boy have things changed over the years.



My experience with programming? Well, there was Fortran 2 (1960s). And assembly. And good old Basic, many different forms. More assembly. Oh, and real machine language, 0s and 1s (no cheating with hexadecimal) set with a real front panel with 16 switches and some push buttons, one 16 bit word at a time.

Always in small increments. Never as a full time occupation. I am not afraid of C, with or without the "++" I just have to learn it and, as I said, get comfortable with it. I will keep all of the above in mind. Thanks again.