Every passing hour brings the Solar System forty-three thousand miles closer to the Globular Cluster M13 in Hercules - and still there are some misfits who insist that there is no such thing as progress.
Ransom K. Fern
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.
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 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.
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.
We need to download two software packages:
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:
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'...
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...)
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:
-L"c:\Borland\Bcc55\lib"
-I"c:\Borland\Bcc55\include" -L"c:\Borland\Bcc55\lib"
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:
Restart your machine, and you'll be ready to...
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...
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:
That is, you run the program called bcc32, and you pass it the argument hello.cpp. Clear and simple?
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; }
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++.
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.