Jump to content
  • Advertisement
Sign in to follow this  
RobinOfSweden

C++ Compilers?

This topic is 4391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!