This article takes the reader through the acqisition, installation, and setup of the Borland compiler, and shows how to make and use a makefile to build Win32 programs.
The Borland BCC55 compiler can be downloaded from Borland's CodeGear web site (www.codegear.com), upon filling out a registration form. It is free, as are all the Borland C++ Builder tools that come with it, but users are required to give the personal details before they can obtain the package. It is well worth the effort.
Once it has downloaded, it can be installed.
The downloaded file should be double-clicked, and the setup process will begin. If the user chooses all the defaults, the compiler will be installed in C:\BORLAND\BCC55. There are usually no good reasons to change the default settings, but if they are altered, then the reader will have to make their own substitutions for this path in the remainder of these instructions.
Before it can be used, the complier will need some configuration. It is a command line file, and as such does not have a Windows interface. This should not scare the reader off, it is just something to be aware of - there is no 'interface', and as such, there is a little magic involved in getting it to work. Following these (sometimes abstract) instructions will enable that magic to be mixed in.
Start notepad (or your favorite text editor), and copy the following lines into a blank document:
Save the document as C:\BORLAND\BCC55\BIN\BCC32.CFG and start a new one. Copy the following lines into the new document:
This document can be saved as C:\BORLAND\BCC55\BIN\ILINK32.CFG and Windows restarted.
To build a Win32 project from source (that the reader has created themselves), we need three things:
The batch file kicks off the build process. The make file tells the compiler, and linker, what files to include in the project. We also put a few commands in the batch file to enable us to view the results of the compile operation, and tidy up after ourselves. In cases where the build succeeds, the application will be started.
The batch file will remain roughly the same across all projects, with only the make_file_name.mak and application_name.exe needing to be replaced with the real name of the make file and application. This make file is based on a template which we shall cover below. The batch file contents can be cut and pasted from the following:
A few points to note:
The file should be saved in the folder where the source code for the project will be stored. The first line (PATH=...) tells Windows where to find the compiler. The extension to the file should be .BAT ; a Windows (DOS) batch file.
The make file contains all the dependencies (source files) that the compiler will need in order to make the object code that can be used by the linker to create the application. The following is a skeleton (template):
From the above, application_name and object_file_names will usually need to be replaced. For each of the object file names (in the format file_name.obj) there shoiuld be a corresponding source file (ending in .c or .cpp). By a similar token, the file containing the entry point to the application - the WinMain function - should carry the name of the application, as specified in application_name.
So, for example, if a project contains a file MyApp.cpp with the WinMain function (and other Win32 bootsrap code) in it, a resource file MyApp.res, and a source file to handle strings, called MyString.cpp, then we would end up with the following lines in the make file:
We would then substitute MyApp.exe into the batch file, as well. The make file should be saved in the same place as the .BAT file we created above, and with a name ending in .MAK ; this name is also substituted into the batch file. To compile the project, just double-click the batch file. Presto!