Using Borland's Command Line Tools
Page 1: Installation, First Use

Installation, First Use Multi-File Programs
Static Libraries Static Linked and Dynamic Linked
Make Files [1],  [2],  [3],  [4]  [Summary] Create and Use a DLL
Resource Files [1]

On this page:
What is included Installing Finishing Installation Additional Help Files
Using the Tools Calling the Linker Options

What is Included:

Borland's free compiler is the set of command line tools from C++ Builder version 5.

Among the tools are:

  bcc32.exe   compiler
  ilink32.exe linker
  tlib.exe    librarian
  make.exe    a tool for building software projects
  brcc32.exe  resource compiler
  impdef.exe  creates module definition files
  implib.exe  creates import libraries
  tdump.exe   shows information on what a file contains
  grep.exe    searches text files for matching strings
              (greatly useful - learn to use it!)
If you have C++ Builder itself, the command line tools from all versions work in about the same way.  The 32 bit tools from the old 1997 Borland C++ also work much the same way although the linker to use with it is tlink32.exe and not ilink32.exe  ilink32.exe was in a 'preview' stage back then.

Installing:

For those more familiar with Unix or with Linux, note that Windows' file system is not case sensitive.  Commands given from the command line are also not case sensitive but program options on the command line ARE case sensitive.

What you downloaded is an executable file to install the compiler.  When you run it the program will install the tools on your machine.  It will ask you where to place the tools.  If you accept the default location they will be installed into c:\borland\bcc55

If you elect to specify a location for the tools, deciding to not accept the default, do NOT specify a location whose directory names include the plus character (the '+'). The Windows file system will accept directory names such as 'C++' but the Windows command interpreter sees a plus character as a file concatination command and the result will be that commands using the tools will have problems.  This is a characteristic of the Windows command interpreter and not of Borland's tools.

Finishing the installation:

Among the files which are installed is a README.TXT file.  Read that file.  It tells how to create two required configuration files, bcc32.cfg and ilink32.cfg, in the compiler's BIN directory.  Read the file and create the configuration files before doing anything with the compiler.  Note that the text to place into bcc32.cfg includes the characters '-I'.  That is a capital 'i' and not a lower case 'L' or a one.

If you are using Windows 2000, Windows XP or Windows ME there is another step.  The README.TXT file speaks of modifying the AUTOEXEC.BAT file to place the compiler's BIN directory in the path.  2000, XP and ME do this in a different way.

Windows 2000 and XP:
  Right click on the My Computer icon
  Click on Properties
  Click the Advanced tab
  Click the Environment Variables button
  Select the system variable named Path
  Click the Edit button
  Add a semicolon, a ';', to the end of the string
    followed by the proper path (default is c:\borland\bcc55\bin)
    check that there are NOT two ';' in a row!

Windows Millenium Edition (Windows ME):
  Select
    Start|Programs|Accessories|System Tools|System Information
    This brings up a window titled "Microsoft Help and Support"
  Choose the tools menu
  Select the system configuration utility
  Click the environment tab
  Select PATH and press the edit button
  Add a semicolon, a ';', to the end of the string
    followed by the proper path (default is c:\borland\bcc55\bin)
    check that there are NOT two ';' in a row!

Note that while many run the compiler under ME it is not certified for ME

Using the tools:

Read this page:
   [Overview of Compiling and Linking]

The compiler's job is to create an object file from each source code file that you provide.  Source files are named with an extension of .C for C language files and of .CPP for C++ language files.  Object files have an extension of .OBJ

If you specify for it to do so, the compiler will call the linker, the tool which combines the object files into the target file, an executable program (file extension .EXE) or a dynamic linked library (file extension .DLL), any of which can be dynamic linked or static linked, single threaded or multi-threaded.

The typical first task done by someone new to the tools is to build a "Hello World!" program.  Because these tools are command line tools, they work from the command line in a console window, a text window whose appearance is similar to an MSDOS window. They do not use a graphical (GUI) screen.

Here is the source code to such a program, the file hello.cpp
  // -------HELLO.CPP--------
  #include <iostream>
  using namespace std;

  int main()
    {
    cout << "Hello World!" << endl;
    return 0;
    }
  // ------------------------
Use an editor to create that file. If you do not have an editor, give the command Notepad to start an editor that came with Windows.

Build the program with this command:
  bcc32 -WCR hello
  (the compiler assumes a file name extension of .CPP)
The -WCR is a command line option telling the compiler to create a Windows console mode program that is dynamic linked.

If you are using Borland C++ and not C++ Builder (note that version 5.5 is C++ Builder, not the old Borland C++) then the dynamic linking option on the compiler command line is not available.  Use -WC instead.

Give the command DIR to see the files in the directory.  You should see the original hello.cpp but also should see hello.obj, hello.tds and hello.exe

hello.obj - the object file created by the compiler.  It contains the machine code generated from your source file along with information on the variables in the code and the header files used.

hello.tds - a 'helper' file used by the linker.  While not done here, had you elected to have debug information generated (so you could debug the program), that information would also be in the TDS file.

hello.exe - this is the executable file, the program.  To run it give the command
  hello
(A file name extension of .EXE is assumed but if you wanted to use it, hello.exe would also work.)

Note: Sometimes you have a source file that generates a screen or more of errors.  You can use redirection to place the errors in a text file so that you can open both the source file and the errors file in your editor.  A command line to do that is below.  It creates the file errors.txt.
  bcc32 -WCR hello >errors.txt

Building the program but calling the linker yourself:

Compile to an object file and then link the object file to an executable.  The result of this should be the same as was done by the single bcc32 line above.
  bcc32 -c -WCR hello
  ilink32 /Tpe/ap/Gn/x/c c0x32 hello,hello,,import32 cw32i

  compiler items
  -c says to not to call the linker.

  linker items
  /Tpe - create an executable file (an exe file)
  /ap - mark the file as Windows console mode
  /Gn - do not create intermediate linking files (*.il? files)
  /x - do not create a map file (*.map)
  /c - do case-sensitive linking (C and C++ are case sensitive)
  c0x32.obj - startup code for console mode programs
  import32.lib - import library for what Windows provides
  cw32i.lib - import library for the compiler's runtime code
	      (where items such as printf and cout are found)

Note that the commas on the linker command line separate different parts of what it is being told. Certain types of files normally appear in each of those parts and each of those file types has an extension that is commonly used. The linker knows those extensions. That is why in the example above it was not necessary to put the .obj, .exe and .lib extensions on the command line. In this case it is of little value to call both the compiler and linker yourself.  For a project in which there is only one source file it is easier to let the compiler do the rest of the work for you.

The above lines use a dash ('-') for the compiler options and a slash ('/') for linker options.  Both programs accept either of dash or slash.   Linker command lines tend to be very long and options with a slash do not require a space between them.  Slashes are commonly used in linker command line options.

Compiler and Linker Options:

If you run either of the compiler, bcc32.exe, or the linker, ilink32.exe, with no command line parameters, a summary of how to use them will be shown.  The summary shows how the command line is constructed and the options that can be used.

The help file shows a more complete description of these things.  To use the help do this:

  Start the help.
      winhlp32 c:\borland\bcc55\help\bcb5tools.hlp
      (or double-click on it in Windows Explorer)
  Click on the Index tab.
  Type BCC32 into the edit control.
  Click the Display button.

To get help on the linker, repeat what is above but with ILINK32 in the edit control.

Note that capital letters are used above for BCC32 and ILINK32 only for emphasis.  The help system is not case-sensitive.

Additional Help Files

To keep the free compiler download at a managable size only one help file is included.  Borland has posted help file updates for version 5, the version from which the free compiler is taken.   [Help File Updates Link]

Not all of those help files deal with what the free compiler package includes.  Those which are most likely to be of use with it are:
B5RTL.ZIP B5MS.ZIP B5SCL.ZIP B5ERRS.ZIP
 
 
[Next Page: Multi-File Programs]

:: Main | Search | Site Map
 
:: Algorithms & Code
:: Assembly & Low Level
:: Borland/CodeGear
:: C & C++
:: CGI
:: CDROM Info
:: COM/DCOM/CORBA
:: Communications
:: Compression
:: Cryptography
:: File Formats
:: General Software
:: Games & Graphics
:: Hardware
:: HTML, Web Development
:: Linux/Unix/BSD
:: Microsoft
:: Miscellaneous
:: Neural Nets
:: New Links
:: Programming Articles
:: Programming Languages
:: Protocols
:: Sfwe Publications
:: Sfwe Sellers
:: Std Template Lib/STL
:: Tutorials, Refs: C/C++
:: Tutorials, Refs: Other
:: Utilities & Tools
:: XML & XHTML
:: Windows, Win32
:: 8051 & Embedded
  Programming Pages 
::  #1 #2 #3 #4 #5 #6 #7
Valid HTML 4.01 Strict