Sunday 26 February 2012

Compiling With Borland

Borland is one company that create compilers. In the past, they released a version of C++ called Turbo C++ that was popular for programming in the DOS enironment, and you may find some books still come with that compiler. For more information, you can visit borland's website.If you have not downloaded borland yet download it here(you have to submit a form and the download link will be sent to your email address).

Setting up Your Compiler

Once you've downloaded the Borland compiler, you can take take the default installation options, including the default directory, "c:\Borland\BCC55". Once you've done that, follow the instructions below to get the compiler ready to use.
  • First, we need to tell the compiler where to find the include files and supporting libraries. To do this, open up notepad (or any other text editor) and paste the following two lines into a blank file:
    -I"c:\Borland\Bcc55\include"
    -L"c:\Borland\Bcc55\lib"
    
  • Save this file in notepad as "c:\borland\bcc55\bin\bcc32.cfg". To do this, just go to "Save As" under the "File" menu, then type the entire file name, in quotes, into notepad. You need to include the quotes to keep it from adding a .txt extension.
  • Now paste the following line into a new blank text file:
    -L"c:\Borland\Bcc55\lib"
  • Save this new file as "c:\borland\bcc55\bin\ilink32.cfg"
Great, now you're ready to start writing and compiling programs.

Compiling and Testing your Installation

Since Borland C++ 5.5 is a command-line tool, you will need to run it from the command line. Before trying to compile a program, you'll need to actually write some code to test the compiler. You can do this in notepad, or download a better text editor. At any rate, you'll want to save the file in the "c:\borland\bcc55\bin" directory. If you save it in notepad, be sure to enclose the name in quotes to make it a ".cpp" file instead of a ".txt" file. 

Here's a simple program you can copy into notepad and save as "c:\borland\bcc55\bin\test.cpp" to test your compiler's installation:
#include <iostream>

int main()
{
    std::cout<< "I Have Succeeded!" << std::endl;
}
Borland C++'s compiler is actually named "bcc32" and it is located in the "c:\borland\bcc55\bin" directory; the below instructions will take you through compiling your first program.

Compiling the program

  • Go to start, click on run, and type "Command", and hit enter.
  • Now, type "cd c:\borland\bcc55\bin" and hit enter.
  • You should be in the above directory now (your prompt should read: "c:\Borland\BCC55\Bin"); if not, check that you typed it correctly.
  • Type in "bcc32 test.cpp" and hit enter. This should result in the following output if everything worked:
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    test.cpp:
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    
    which means that it worked.
  • You can now run your test program by typing "test.exe" and hitting enter. You should see the text:
    I Have Succeeded!
    

2 comments:

Anonymous said...

Thank you so much,specially for the download link.I could not find it on the net except for the frauds.

With Regards,
Mike

Alex said...

Anytime. :)