Programming
27 December 2010 1 Comment

Setting Up Borland C Compiler on Windows

While Linux users will in most cases use the GCC compiler, this tool is not available for windows as a standalone binary. Using the Borland C++ Compiler is a good way to start developing  C/C++ applications on Windows.

Unfortunately, setting it up is not as easy as you would expect. In this how-to I will show you how to set up the compiler quickly, so you can hit the ground running. Please notice that anytime the C:\Borland\BCC55\ directory is mentioned, this should be substituted with your own installation directory.

1: Download the Borland Compiler

Borland is no longer hosting this file themselves. The latest version is available from the Embarcadero website: click here. Select C++ Builder XE, then click C++ Compiler 5.5. You will have to register to download, but no activation-code is used. You can enter an invalid e-mail address if you like your privacy. Download the file freecommandLinetools.exe to your harddisk.

Note that, even though the name suggests it only compiles C++, this compiler also supports C!

2: Run the setup program

Run the freecommandLineTools.exe program, and install to any directory. The default is C:\Borland\BCC55\.

3: Change your PATH settings

The PATH variable is used by your command prompt (cmd.exe) to look for executables that are not in the current working directory. In order to run the compiler from anywhere, without having to specify the full path, you should set this up: press Windows Key + Pause, and go to Advanced System Settings. Select Environment Variables, and check if a User Variable named PATH exists. If it does not exist create it, using the Variable Value: C:\Borland\BCC55\bin, or where-ever you installed it.

If the variable already exists, add the following:

;C:\Borland\BCC55\bin

Notice how the semicolon is used to string multiple directories together. The value associated with your PATH variable might now look like this: C:\Foo;C:\Borland\BCC55\bin.

Note that if you have a cmd.exe window open, you will need to close and re-open it before the environment variable changes are reflected.

4: Set up the BCC configuration files

Without some configuration the compiler will not know where find certain resources, so it will not compile anything right now. The readme file in the installation directory gives some hints on what configuration files are required, but it forgets to mention where to put them. Follow the steps below to set things up correctly:

  1. Create a file called bcc32.config in your C:\Borland\BCC55\bin directory.
  2. Open this file in a text-editor, add the following lines, and save the file.
    -I"C:\Borland\BCC55\include"
    -L"C:\Borland\BCC55\bin"
  3. Create another file, called ilink32.cfg in the same bin directory.
  4. Add a single line to this file, and save it:
    -L"C:\Borland\BCC55\bin"

5: Start coding!

That’s it. You can now create a small C test-program to check if you are up and running.

Create a file called test.c anywhere on your harddisk containing a cheesy greeting:

1
2
3
4
5
6
7
#include 
 
int main(void) 
{ 
  printf("Hello world!n"); 
  return 0; 
}

Open a command prompt (Windows+R -> cmd.exe) and navigate to test.c‘s directory. Then type bcc32 test.c to compile your application. The output should look like the below image.

You can now execute the application by typing test.exe (or just test). If all went well, you should see “Hello world!” printed on the screen.

Happy coding, until next time.

Tags: bcc32, borland, , compiler, embarcadero, path

One Response to “Setting Up Borland C Compiler on Windows”

  1. Dattatreya 17 August 2012 at 6:02 am #

    it seems in given present version of borland c++ compiler, the 1st files mentioned in step4 should be saved as bcc32.cfg and not as bcc32.config.

    As ‘readme’ file says, the second line in this file should be..

    -L”C:\Borland\BCC55\lib”

    not

    -L”C:\Borland\BCC55\bin” ……

    similarly in ilink32.cfg file >

    the line should be changed as
    -L”C:\Borland\BCC55\lib”

    Reply