Borland sells a wide range of development tools. These tools are quite useful. However, many people, especially students just learning about programming, need something cheaper (preferably free!) to work with. Borland has been kind enough to provide a free command line compiler. It is the one used throughout most of this book (except for the chapters on Visual C++). This appendix will walk you through the download, installation, configuration, and use of this free compiler.
Step 1: The first step is to download the compiler. First, you will need to go the Borland Web site, where there is an entire page devoted to this free compiler.
You can simply click on “Try it Now” on the lefthand side of the screen, just as you see in Figure D.1.
Once you select that option you will be prompted to register with Borland, and then to download the compiler to your machine. What you actually download is a setup file that you will need to run. Figure D.2 is a picture of what it would look like if viewed in “My Computer” on a Windows PC.
Once you launch the application, it will ask you where you wish to install the product. This will look much like the image in Figure D.3.
Once the installation is done, you will have to configure the compiler. In whatever directory you install this compiler to you will notice the following items:
A Bin directory
An Examples directory
A Help directory
A Lib directory
An Include directory
Please note that, although this is a good compiler, the readme file is of almost no help at all. The first step you will have to do is to create two text files called bcc32.cfg and ilink32.cfg. These are configuration files that tell your compiler where to find things. To create them, open your favorite text editor and enter the following.
In bcc32.cfg I"c:\Borland\Bcc55\include" L"c:\Borland\Bcc55\lib;
What these two lines will do is to tell the compiler where it can find include files, and libraries.
In ilink32.cfg L"C:\Borland\Bcc55\lib;
This line tells the linker where to find libraries that need to be linked-in when your program is compiled.
If you installed this to a different directory, then you will have to put the path to the following directory: c:\Borland\Bcc55\
You are almost ready. Now you just need to add this path to your system’s path variables. Path variables allow your operating system to know where to find things. This is done different ways for different operating systems. If you have Windows 2000, then you will go to Start > Control Panel > System, and choose the Advanced Tab. Next, click the Environment Variables button. Then select Path. This should look much like what you see in Figure D.4.
When you click the Edit button, you will see a path statement. At the very end, simply place the following line.
This should resemble the image you see in Figure D.5.
If you installed to a different directory, then please use that directory path.
Now you are set, and ready to compile!
If, however, you are using an older version of Windows, you can go to the DOS prompt and type-in the following.
Set path = %path%;c:\Borland\BCC55\Bin;
For any operating system, you can simply consult the documentation of that operating system and find out how to set the path statement. What you are doing, whatever process is required, is letting the operating system know where the compiler is located, so that you can invoke it from anywhere on your PC. Now you will be able to compile your C++ programs. Simply save your code in a plain text file that ends with a .cpp extension. Then, from the command line, type-in the following.
When that is completed, if there are no errors in your code, you will then have an executable you can distribute: filename.cpp
If, however, you have errors, then you will need to correct those before you will be able to proceed.
If, for any reason, setting the path statement does not work, you can get around this by copying the source file you wish to compile to the folder where your compiler is: