Which C++ Compiler To Use?, Which C++ compiler to use?

vickyrare

vickyrare
Apr 21, 2009
103
0
21
Karachi
Compiler:

A compiler is a computer program (or set of programs) that transforms source code written in a computer language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.

Linker:

In computer science, a linker or link editor is a program that takes one or more objects generated by a compiler and combines them into a single executable program.

You need both to create applications and libraries.

Compiler and linkers are very important in order to develop application. All compilers and linkers require some flags, which derives the process of compiling and linking.

The gist of this article is not to about what are compiler and linker, but to highlight which one to use. It all depends on what you are trying to achieve and on what platform. The compilers discussed here are only for C and C++.

Windows Platform:

If you are planning to develop an application on Windows platform then you have many options such as using Visual C++ compiler by Microsoft, Borland C++ compiler or using Intel C++ compiler. The latest version of Visual Compiler is VC8, but you can still use older versions such as VC6. Visual Studio 6 comes with VC6 while Visual Studio 2003 comes with VC7.1. If you are after the latest and the greatest then stick to VC8 which comes with Visual Studio 2008. Visual Studio has everything such as compiler, linker and debugger to create applications. It gives you a one window solution. You have to pay for the Visual Studio as it is a complete IDE. You can still download the VC++ compiler which they distribute as Express Edition. You can download the Express Edition from Microsoft website.

http://www.microsoft.com/express/vc

Linux Platform:

If you are planning to develop an application on Linux platform (Ubuntu, Fedora, Suse etc.) then the most obvious choice will be GCC (GNU compiler collection). It comes built-in with all Linux based OS. The latest version is 4.3.

GCC:

The GNU Compiler Collection (usually shortened to GCC) is a compiler system supporting various programming languages produced by the GNU Project. GCC is a key component of the GNU toolchain. As well as being the official compiler of the GNU system, GCC has been adopted as the standard compiler by most other modern Unix-like computer operating systems, including GNU/Linux, the BSD family and Mac OS X. GCC has been ported to a wide variety of computer architectures, and is widely deployed as a tool in commercial, proprietary and closed source software development environments. GCC is also available for most embedded platforms, for example Symbian[3], AMCC and Freescale Power Architecture-based chips[4]. The compiler can target a wide variety of platforms, such as the Playstation 2[5] and Sega Dreamcast.[6] Several companies make a business out of supplying and supporting gcc ports to various platforms, and chip manufacturers today consider a gcc port almost essential to the success of an architecture.

GCC gives you both compiler and linker but you have to use an external debugger in order to debug the code. People mostly use GDB and DDD debugger to debug on Linux platform.

GCC is open source so you don't have to pay anything at all. You can download it from

http://gcc.gnu.org/gcc-4.3/


A sample session with GCC:

If you have got a simple C++ file hello.cpp which contains following code then

#include <iostream.h>

using std;
int main()
{
cout<< “Hello World !”<<endl;
return 0;
}


you can compile the code by typing this onto a shell window.

> g++ -c hello.cpp

this command compiles hello.cpp and gives you hello.obj.

Now type in this command to link and create the executable.

> g++ hello.o -o hello

or you can do both compiling and linking in one go

> g++ hello.cpp -o hello

change the permission of executable

> chmod +x hello

run the executable by

> ./hello

External resources:

http://en.wikipedia.org/wiki/Linker
http://en.wikipedia.org/wiki/Compiler
http://en.wikipedia.org/wiki/Visual_studio
http://en.wikipedia.org/wiki/GNU_Compiler_Collection
http://www.gnu.org/software/ddd/


This article heavily uses material from www.wikipedia.org
 

Rapchik Killer

Well-known member
Jan 18, 2007
1,263
0
41
34
Karachi, Pakistan
Nice info vicky rare! You are doing great work by writing such comprehensive tuts, keep it up!

And one more thing you can also use the mingw to use gcc compiler in windows.. something i prefer when developing cross platform..
 

vickyrare

vickyrare
Apr 21, 2009
103
0
21
Karachi
Hai conscript,

This tutorial is talking about which C++ compiler to use. Nothing to do with VB. Although you can compile VB code with Visual Studio.
 
General chit-chat
Help Users
We have disabled traderscore and are working on a fix. There was a bug with the plugin | Click for Discord
  • No one is chatting at the moment.
    NaNoW NaNoW: ....