Skip over navigation

The Lost continent of

You've found a bug on my site!

The oldest books are still only just out to those who have not read them.

Samuel Butler

Borland C++

A good, free compiler for Win32 systems

Update — Dec 2004

This article is starting to age a little now. There are now a number very capable, free compilers for almost every platform, most notably the GNU Compiler Collection (GCC). It's the default compiler on Linux and Mac OS X machines already, and can also be downloaded for Windows. The general notes on setting up the text editor as an IDE apply equally as well to whatever compiler you use.


In mid-February 2000 the people responsible for Borland's C++ products made the core of their product line available as a free download.

What?

They are giving away are the command-line compiler tools and libraries. These are the core of the retail Borland programming tools, like Borland C++ Builder - all the power that runs these expensive products, but without the fancy, user friendly graphical interface - you have to pay for that...

The aim of this tutorial is to get beginners up and programming in C++, easily and cheaply, using a nice friendly replacement for Borland's own expensive GUIs. I assume you are capable of downloading and installing a file by yourself, and are using some variant of Microsoft Windows.

Why?

Why would you want to use this C++ compiler?
Presumably you want to learn and use C++. This compiler is fast and free. These tools look like they run in DOS, but are full 32 bit Windows programs, and will only run in Win9x/NT and above. If you're a command line freak and want to compile under DOS, forget it — and use Linux.

How?

The main problem with this free C++ compiler is that it's very hard for the average computer user, brought up on Windows, to use. No buttons to click, just all sorts of magic invocations that have to be typed in by hand at the command prompt (the what?).

To overcome this learning curve a little, this tutorial will guide you through downloading and setting up the free tools, and setting up a nice friendly Windows interface to work from. We'll be using my favourite text editor, EditPlus, but other programmers' text editors can be setup in a similar fashion.

Step 1) Get the Software

We need to download two software packages:

  1. The Free Borland C++ Compiler and Tools, and
  2. EditPlus, the text editor that's going to act as our user-friendly interface to the tools.

The text Editor's the easiest, just go to www.editplus.com, download and install the current version (about 1MB). For the purposes of this document, we are using version 2.x. EditPlus is shareware, so if you end up using it, do remember to buy it.

Getting the Tools from Borland took me a long while. At the Borland website, as of February 2000 (the month this free offer started), you needed to have both cookies and Java script enabled on your browser. I had neither at first. Hopefully this situation will change, and it will all become a little easier to access. You need to go to http://community.borland.com, Register, then fill in a questionnaire before you can download anything. You should then be given a link to download the package from. It weighs in at about 8MB.

Don't install the Compiler yet, we'll cover that in the next section:

Step 2) Setting up the Compiler

This is the part where most new programmers will get unstuck. The instructions that come with the free Tools package are terse to say the least — not very helpful where you are unsure about how to set your 'Path Environment Variable'...

a) Install Compiler & Tools

First of all, decide where you are going to install this stuff. It'll use about 50MB of space. The default choice is C:\Borland\BCC55, and unless you have a good reason for putting it elsewhere, this is fire. Double clicking on the file you downloaded will take care of this part.

(Of course, if you decided NOT to install the package in C:\Borland\BCC55, substitute the full path to your chosen folder (eg. d:\borland) whenever I quote C:\Borland\BCC55 in these instructions...)

b) Configure Compiler

The installation package just copies files to your computer. You have to manually configure it to work on your system. First of all you need to create two config files to your C:\Borland\BCC55\bin directory, namely ilink32.cfg, and bcc32.cfg.

Create a new text file (in EditPlus, say), add the given text, then save the file into the appropriate place:

In the file C:\Borland\BCC55\bin\ilink32.cfg

-L"c:\Borland\Bcc55\lib"

In the file C:\Borland\BCC55\bin\bcc32.cfg

-I"c:\Borland\Bcc55\include"
-L"c:\Borland\Bcc55\lib"

c) Let Windows Know

Your compiler is now rockin', but you have to tell Windows about it. You do this by adding your 'bin' directory ('bin' for binary, or executable file...) to you default Windows Path. The Path is a list of directories that Windows searches through when asked to run a command... Windows NT/2000/XP and Windows 95/98 differ here, so we'll break off to separate sections:

  • Windows NT/2000/XP
    1. In the Control Panel open the 'System' applet.
    2. Go to the 'Environment' page.
    3. Halfway down the page you will find a list of User Variables.
    4. Click the 'path' variable.
    5. In the section below, you can see two edit controls, 'Variable' and 'Value'. Make sure that the variable being displayed is 'Path'.
    6. We need to add 'C:\Borland\BCC55\bin' to this. If there is already something there, type a semi-colon (;) at the end, then add our installation path.
  • Windows 95/98/ME
    1. Find the file 'Autoexec.bat' (if you only have one or more files called just Autoexec, then ours is the one with an icon that looks like a Cog wheel in a blue frame).
    2. Right click the file, and choose 'Edit' from the pop-up context menu.
    3. A
    4. t the very bottom of this file type, on it's own line, the following:
      PATH=%PATH%;C:\BORLAND\BCC55\BIN

Restart your machine, and you'll be ready to...

Step 3) Configure your Text Editor

We are going to be using the text editor you downloaded in Step one, EditPlus, a great shareware editor. It is very good at interfacing with command line tools like our free compiler, even without much configuring. The following instructions are for Version 2, but Version 1 differs only very slightly...

  1. From the main menu choose Tools » Configure User Tools
  2. Click Add Tool
  3. Name it BCC32, and browse to the BCC32.exe program in the C:\Borland\BCC55\Bin folder.
  4. Choose Filename from the list of Arguments, and File's Directory as the initial directory.
  5. Make sure Capture Output is ticked.
  6. The text editor is now configured as a light-weight IDE. You can invoke the compiler on your text files by pressing <Ctrl>+1. If you get any error messages from the compiler, you can double click the message it to jump to that line of your program.
  7. If all goes well you should find an .exe file you can run in your source directory. Try running it from a command prompt.

The Command Line Way...

The whole aim of this tutorial is to wean beginner programmers away from expensive, commercial IDEs, and lead them to the powerful and FREE (if sometimes intimidating) world of command line programs and opensource software.

What you are doing with the text editor here is getting it to automate a few tasks for you. When you compile a .cpp file, say hello.cpp by pressing <Ctrl>+1 it's as if you were to type at a command prompt the following:

bcc32 hello.cpp

That is, you run the program called bcc32, and you pass it the argument hello.cpp. Clear and simple?

Step 4) Testing, and the FAQ

You are now able to compile simple C and C++ programs by simply typing 'em in and pressing Ctrl+1. Try it with the following (This is standard C++, not the C that many 'C++' tutorials will teach you...):

//  Hello World
///////////////////
#include <iostream>
using namespace std;

int main()
{
	cout << "Hello World!" << endl;
	return 0;
}

Where to from here?

You will very quickly out grow this method of programming — one file programming is only really sufficient for learning purposes. You will need to learn about Makefiles if you want to write larger programs while sticking to free tools. I have compiled a list of useful books for those who want to learn C++.

Integrated Development Enviroments

IDEs such as Microsoft Visual C++ can make things seem easier, but only by hiding details that you should really know about. They also limit you to writing platform specific programs - i.e. Windows only. That said, if you just want to learn C++, an IDE sometimes makes starting out. I have heard some good things about Bloodshed Dev-C++, a modern free IDE for Windows.

FAQ

I pressed Ctrl+1 and got an error: Could not open ilink32
This is by far the most common message I get regarding the tutorial. If you get this, you did not follow step (2b) properly. Reread the instructions and try again.
Where is my program?
Its in the directory where you saved the source code for your program... You may want to open a command prompt, and run your program from there.
My program ran in a DOS Window that just flashed up
See above...