C++ Compilers?

Started by
30 comments, last by RobinOfSweden 17 years, 6 months ago
Hi! Which is the easiest C++ compiler for beginners? I have tried Visual Studio but it was too hard. I tried Borlands compiler (but it didnt like me and I didnt like it ;)) I have also tried Dev-C++ which i kind of like. Is there any better/easier compilers for beginners? Thanks/ Robin
Advertisement
All compilers are equivalent. You can then choose to use an IDE (Visual Studio, Code::Blocks, a correctly configured emacs) or a simple text editor (unconfigured emacs, vi, notepad, crimson editor).

The simplest I found was command-line g++ : run g++ *.cpp and your program is compiled as a.out, which you can then run.
ok...I have had problems with different compilers though (they dont handle the code in the same way. This worked in Visual Studio:

#include <iostream>
int main()
{
std::cout << "Hello, World!" << std::endl;
return 0;
}

While I had to write like this in Dev-C++:

#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
return 0;
cin.get();
}

And in Borland C++ Compiler, neither of these two worked.
Quote:Original post by RobinOfSweden
ok...I have had problems with different compilers though (they dont handle the code in the same way.


They should. If they don't, check if you are using them properly, and then contact the compiler distributors to notify them of the discrepancy. The example you gave for Visual Studio is correct, and should work on all standard-respecting C++ compilers.
Ok...I really wanna learn to use Visual Studio. I know where to write the code etc. but I dont know what type of projects Im supposed to create (theres tons of em). I also dont know how to compile the program and test it (without actually doing a complete build). Do you know where to learn this? (I hate the Help Documentation).

Thanks/ Robin
I just want to say that you shouldn't write any commands after the return statement:
#include <iostream>using namespace std;int main(){cout << "Hello, World!" << endl;cin.get();return 0;}
Oh....just wrote wrong in the message... I wrote it correctly in the compiler though (before the return statement as you said...)

Thanks/
If you're just starting with C++, 99% of Visula Studio's features you can totally ignore for now. All you need to do is always create a "Win32 Console Project". Add source files by using "Project->Add New Item" and choosing .cpp or .h. Compile your code with "Build->Build Solution". And run it with "Debug->Start Without Debugging".

When you are comfortable with this (and with C++), you can learn the other features, like using the debugger and creating graphical apps.

Hope that simplifies things for you.
Thanks!

Really apppreaciate the help :)

One more thing...when creating a Console Application. What does the #include "stdafx.h" command do (the stdafx.h seems to be required, but what is it for)?

/Robin
Oops, that's my bad, I forgot one important step. Be sure to check the "Empty Project" box when creating a new project. This tells the IDE that you don't want it to setup its little framework for you.

In case you're curuious, I believe the stdafx.h file is for precompiled headers, though I have never used this feature.

This topic is closed to new replies.

Advertisement