Creating Executables
Of course, the software on your computer isn't all a bunch of code in a high level language, at least not in the form you receive it in. Before you can run any programs which are written in C++ or Java, they must be compiled. Compiling is the process by which a computer reads the code which you have written and interprets it. Usually, this is followed by the creation of an executable file. Executables are files which can be run by a user, like programs.

Compiling Your Code
To compile a program, you need to make use of a compiler. Each programming language available requires its own compiler to process the code. For example, one needs one of the many C++ compilers to process C++ code, similarly to how one needs a Java compiler to process Java code.

There are numerous compilers available, each one specific to a particular operating system and language. While free ones are available, they often prohibit the use of legally selling the software you create with them. It goes without saying that each compiler may have its own little quirks. For example, while trying to compile one of your programs, you may receive a simple warning when using one compiler. While using a different compiler, however, you may generate a programaming error, prohibiting your code from being compiled at all.

One of the most well known compilers for Windows machines is Microsoft Visual Studio 6.0, consisting of Visual C++ 6.0 and Visual J++ 6.0 (which can be purchased stand-alone as well). This program allows you to write software for Windows 9x/Me, NT, 2000, and XP.

Yet another very good compiler for Windows is made by Borland ... Borland C++ Builder and Borland JBuilder. They also offer free stripped-down C++ and Java compilers through their website.

Using A UNIX Compiler
Of course, the UNIX / Linux operating systems also make use of their own compilers. Compiling C++ on a UNIX box often involves the use of gcc, one of the original UNIX-based C++ compilers. This handy lil terminal-based program is commonly distributed with the operating system itself. To compile, simply type the following in a terminal:


g++ file.C -o executable_name

Of course, your new executable file can then be run by typing ./executable_name. Note that file.C represents the original name of the C or C++ source code, and executable_name is the name of the location where you wish to put the new file to be created. If the file already exists, it will be overwritten automatically.


I would like to start learning C++ (on an iMac G4) - Do I need to download C++ compiler? If yes, could you advise where I can download it?

Thanks!

If you are using OS X, the gcc compiler comes with the BSD subsystem. It's an optional component to install during OS X setup.

Creating Executables
Of course, the software on your computer isn't all a bunch of code in a high level language, at least not in the form you receive it in. Before you can run any programs which are written in C++ or Java, they must be compiled. Compiling is the process by which a computer reads the code which you have written and interprets it. Usually, this is followed by the creation of an executable file. Executables are files which can be run by a user, like programs.

Compiling Your Code
To compile a program, you need to make use of a compiler. Each programming language available requires its own compiler to process the code. For example, one needs one of the many C++ compilers to process C++ code, similarly to how one needs a Java compiler to process Java code.

There are numerous compilers available, each one specific to a particular operating system and language. While free ones are available, they often prohibit the use of legally selling the software you create with them. It goes without saying that each compiler may have its own little quirks. For example, while trying to compile one of your programs, you may receive a simple warning when using one compiler. While using a different compiler, however, you may generate a programaming error, prohibiting your code from being compiled at all.

One of the most well known compilers for Windows machines is Microsoft Visual Studio 6.0, consisting of Visual C++ 6.0 and Visual J++ 6.0 (which can be purchased stand-alone as well). This program allows you to write software for Windows 9x/Me, NT, 2000, and XP.

Yet another very good compiler for Windows is made by Borland ... Borland C++ Builder and Borland JBuilder. They also offer free stripped-down C++ and Java compilers through their website.

Using A UNIX Compiler
Of course, the UNIX / Linux operating systems also make use of their own compilers. Compiling C++ on a UNIX box often involves the use of gcc, one of the original UNIX-based C++ compilers. This handy lil terminal-based program is commonly distributed with the operating system itself. To compile, simply type the following in a terminal:

g++ file.C -o executable_name

Of course, your new executable file can then be run by typing ./executable_name. Note that file.C represents the original name of the C or C++ source code, and executable_name is the name of the location where you wish to put the new file to be created. If the file already exists, it will be overwritten automatically.

does borland free compiler have any short-coming too like other free c++ comilers?
is it in it's fullest version?

does borland free compiler have any short-coming too like other free c++ comilers?
is it in it's fullest version?

where will i get C compiler free download

i need tutorials for c language so where i will get them

Borland free C++ compiler i.e version 5.x does not come with and editor or and IDE.
But I heard they did release version 3.x compleately free along with the IDE.Go get that one if you can.

http://www.borland.com/

FireNet,
thanks, i will get the ver3 now. but can u pls tell me more about the IDE stuff?

FireNet,
i've got it. but have not known how to use it. it's always giving the message:
Failed to locate protected mode loader (DPMILOAD.EXE).
can u put me thru. in using it?
thanks.

i too would like to know how to use these compilers. i used a tutorial i found on called yabasic and it is a good start. i have some things i want to compile so i downloaded visual c++ free for my xp platform. i cant figure out how to use it and execute my simple code im working on. It doesnt help that they dont include newbie instructions :confused: anyone know how to run code on v++ ??

thanks
jeff

A GREAT free C/C++ Compiler is Dev C++ 4.9.9.0, i love it, its great!

A GREAT free C/C++ Compiler is Dev C++ 4.9.9.0, i love it, its great!

Yes it is a quite good compiler and I also use it. However it has some flaws. It can't compile code, that tries to enter vga mode.

FireNet,
i've got it. but have not known how to use it. it's always giving the message:
Failed to locate protected mode loader (DPMILOAD.EXE).
can u put me thru. in using it?
thanks.

That sounds like a DOS compiler wanting to switch to DOS protected mode.
What are you using? Borland C++ 3.0?
Get the latest Borland C++ Builder (there's a free version) instead, it will do both GUI and command line Windows applications.

As to restrictions: it comes with less components for building systems by click and drag and doesn't allow commercial distribution of the created software.
Neither is a restriction when learning the language and the missing components aren't things typically used in freeware stuff either (most deal with relational databases, CGI programming for webservers, and highend stuff like that).

Hi!

I usually use mingw http://www.mingw.org, as this uses a linux compiler gcc, and is therefore very reliable and complies to standards more than any other. It is easier to work with bigger projects using command line, and not so much rubbish files either. I use a vim editor http://www.vim.org, in insert mode it works almost like notepad, but it is useful for so many things. First, it enables to run programs from within editor, which is useful among other things because that way you can run programs in the directory where you are, as windows explorer doesn't change the directory of the shell, it usually remains c:\. And then, to compile, say you use makefile, then you may write a bat file like build.bat, with a command like this: redir -e make.txt mingw32-make -f makefile, of course you can tell vim to run that for compiler as well. Or you can write there the compile command directly, makefile is something like:

CC = gcc
CFLAGS = -W -Wall -O3 -mno-cygwin -std=c89
-mms-bitfields -std=c89
LDFLAGS = -s -mwindows
TARGET = something.exe
OBJ = something.o Rsrc.o
all: $(TARGET)
Rsrc.o: Rsrc.rc
	windres -o Rsrc.o Rsrc.rc
$(TARGET): $(OBJ)
	$(CC) $(LDFLAGS) -o $(TARGET) $(OBJ)
Rsrc.o: Rsrc.rc
something.o: something.c something.h

Or there are many ways. But important here is that make.txt, as that command redirects the error messages there. And here comes onother thing the vim is useful for, write :cfile make.txt, and then every :cnext brings you to another error, in whatever file it is, comes also easily out jus by : and up arrow. And yes, mingw can certainly compile programs which use graphics, also opengl. But then it's better if you use gtk http://www.gtk.org for that, not windows api, as this enables you to write portable programs, which can be compiled on linux as well. And of course all these things are freely downloadable, even more they are open source, and mingw is even public domain. I guess you don't think the compiler linux was written in is too restricted, believe me these are reliable things, good tools for good programmers. I could say quality tools, but this is more about advertising commercial products, often with not so high quality as it is said. And they are not made only by enthusiasts, also by universities and private companies.

As a reply to the previous post, mingw is public domain, other things are at least glpl, so you can not only use them for free, but also write a commercial programs with them, and sell these programs, without paying anything to anybody.

About installing mingw, in case you don't know, it's easy, just download it and run the installer. But then, say you use windows 2000 or xp, go to start > settings > control panel > system > advanced > environment variables. There is a box called user variables. See if there is a variable PATH, if there is, press edit, otherwise press new and create that variable. This is a set of paths separated by semicolon, the path you should add there is \mingw\bin, if you installed mingw under the directory \mingw. Press OK everywhere, and the settings change immediately, you don't have to reboot. Now when you run gcc on start > run > cmd, or :!gcc from within vim, the gcc says "no input files" then the mingw works, get some snippets here, compile and run them. That's it, not so very complicated. And you don't need any commercial compilers or ide-s.

Hi!

I usually use mingw http://www.mingw.org, as this uses a linux compiler gcc,

mingw has nothing to do with linux whatsoever.

and is therefore very reliable and complies to standards more than any other.

it complies with a 16-year old version of the ANSI C standard, but that's about it.

Well, I called gcc (http://gcc.gnu.org/) a linux
compiler because it is mostly used on linux, it is the
most often used compiler on linux. See about c standards
http://www.cse.ohio-state.edu/cgi-bin/info/info/gcc,Standards,
also compiles c++, java, fortran and ada. MingW is gcc compiler
ported to Windows, and libraries. The c and c++ libraries for
gcc are complete, but the posix (unix standard) libraries
are only partially implemented. On Windows, cygwin should
be used for full posix support, but this needs a cygwin dll
file for programs to run. BTW, dev-c++ mentioned here, uses
mingw as well, you can also use gcc on command line, when you
have dev-c++. There are also several other ide-s for mingw,
or which can be used with mingw, like visual-mingw, relo,
vide (based on vim), and red hat source navigator (available
on mingw download page).

nice post csgal.
really helped

nerds... :rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.