Sign in to follow this  
RobinOfSweden

C++ Compilers?

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
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
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
Quote:
Original post by RobinOfSweden
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.


Just for the record, I've just compiled both of these with BCC55, the Borland free C++ compiler, and they both compiled and ran as expected.

What errors did you get with these with Borland?

Oh, and Digital Mars have a free C++ command-line compiler that is dead easy to use if you are still considering different options. Doesn't require an installation so you can even run it off a flash stick and stuff and is has one of the fastest compile-link times I've ever seen.

Share this post


Link to post
Share on other sites
Other than what Simian Man said, I'd recommend you learn to use the debugger early on. You can put a breakpoint on a specific line of code by clicking to the left of the line (a red dot should appear). You can use the watch list to examine the values of the variables in your code. F10 and F11 to step through the code. Once you're used to the debugger you'll never have to write debug output to the console ever again :)

Share this post


Link to post
Share on other sites
10000 thanks to all of you guys. Really appreaciate that there's so many hepful people around.

Just for the future... what kind of project am I supposed to create when making Windows Applications (not Console Applications, hope you understand what I mean). And What kind of projects am I supposed to use when creating real 3D games?

Thanks again/ Robin

Share this post


Link to post
Share on other sites
To create a Windows app with VC Express, first you need to install the PSDK (follow the instructions carefully). Then you just do New Project, select Win32 Console Project, click "Next" and select Windows application. That will start you with a skeleton Windows application.

For 3D, your options are varied. Generally a Windows 3D application will use the same basic framework as a normal Windows application but then have an API like Direct3D or OpenGL sit on top of the framework. If you want to have a look at Direct3D, you'll need to download the DirectX SDK as well. There are tutorials and examples in the documentation.

Share this post


Link to post
Share on other sites
Thanks :D

This is the last question, I promise ;)

How much coding etc. do I need to learn in order to Mod games like Half Life 2 (translating subtitles, making weapons do more damage, changing the Main Menu etc.) Do I need any programs/tools?

/Robin

Share this post


Link to post
Share on other sites
To mod a game such as half-life 2(my favourite game [smile] ) you need to learn a scripting language such as LUA.

You should take a look at Garry's Mod. You could be familiar with this mod, but I beleive you can script your own weapons in version 10.

Try downloading it and getting some tutorials on weapon modding for gmod 10 or something. I hope this helps.

Cheers,
Chris

Share this post


Link to post
Share on other sites
I checked out PSDK...but it seems like its only available for Windows Server 2003... does that mean that you need that windows version in order to make Windows Applications and games?

If it does, then I can as well stop learning C++ etc. right away :(

Share this post


Link to post
Share on other sites
Thanks :D...the header just fooled me...it said "Microsoft ® Windows Server® 2003 R2 Platform SDK Web Install"... but when I read the System Requirements at the bottom of the website, I noticed that it worked with Windows XP SP 2 also :D

/Robin

Share this post


Link to post
Share on other sites
Quote:
Original post by RobinOfSweden
I checked out PSDK...but it seems like its only available for Windows Server 2003... does that mean that you need that windows version in order to make Windows Applications and games?

If it does, then I can as well stop learning C++ etc. right away :(

No, you don't need Win Server 2003. You are probably using some version of Win XP which is compatible.

Share this post


Link to post
Share on other sites
Hum,

This doesnt make any sense to me.

Due to the Microsoft webpage i'm supposed to first install Visual C++ 2005 Express Edition, but isnt I supposed to use Visual Studio 2005?

Can someone plz explain step by step what I'm supposed to download and install in order to be able to make Windows Applications, games, console applications etc. with C++.

Thanks/ Robin

Share this post


Link to post
Share on other sites
You've lost me. Do you mean you already have a commercial copy of VS 2005? If so, I guess you don't need to download the PSDK since it would ship with the commercial version.

Have a look in your VS include directory for <windows.h>. If it is in there, you already have the PSDK so you can start making Windows apps immediatley.

Sorry for my confusion. Post back if you meant something else.

Share this post


Link to post
Share on other sites
Actually, I have borrowed Visual Studio 2005, but I dont know if it is a commercial version or not. I had the following file "\Visual Studio 2005\VC\PlatformSDK\Include\windows.h". Is that what you mean?

If it is, can I make windows apps striaight away, and do I need too install DirectX SDK in order to use DirectX?

Thanks/ Robin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this