Getting started with Borland C++ 5.5

In mid-February 2000 the people responsible for Borland's C++ products made the core of their product line available as a free download.

<!-- Main HTML starts here -->

In mid-February 2000 the people responsible for Borland's C++ products made the core of their product line available as a free download.

What?

They are giving away are the command-line compiler tools and libraries. These are the core of the retail Borland programming tools, like Borland C++ Builder - all the power that runs these expensive products, but without the fancy, user friendly graphical interface - you have to pay for that...

The aim of this tutorial is to get beginners up and programming in C++, easily and cheaply, using a nice friendly replacement for Borland's own expensive GUIs. I assume you are capable of downloading and installing a file by yourself, and are using some variant of Microsoft Windows.

Why?

Why would you want to use this C++ compiler?Presumably you want to learn and use C++. This compiler is fast, free, and has the best compliance to the new (1998) ANSI C++ of any compiler out there. (Microsoft's Visual C++ is presented by Microsoft as being simply a 'Windows Compiler', so their terrible adherence to standards might be forgiven - they are still using a 1996 draft of the C++ standard...). These tools look like they run in DOS, but are full 32 bit Windows programs, and will only run in Win9x and NT. If you're a command line freak and want to compile under DOS, forget it - and use Linux.

How?

The main problem with this free C++ compiler is that it's very hard for the average computer user, brought up on Windows, to use. No buttons to click, just all sorts of magic invocations that have to be typed in by hand at the command prompt (the what?).

To overcome this learning curve a little, this tutorial will guide you through downloading and setting up the free tools, and setting up a nice friendly Windows interface to work from. We'll be using my favourite text editor, EditPlus, but other programmers' text editors can be setup in a similar fashion.

1) Get the Software

We need to download two software packages:

The Free Borland C++ Compiler and Tools, and

EditPlus, the text editor that's going to act as our user-friendly interface to the tools.

The text Editor's the easiest, just go to www.editplus.com, download and install the current version (about 1MB). For the purposes of this document, we are using version 2.x. EditPlus is shareware, so if you end up using it, do remember to register it.

Getting the Tools from Borland took me a long while. At the Borland website, as of February 2000 (the month this free offer started), you needed to have both cookies and Java script enabled on your browser. I had neither at first. Hopefully this situation will change, and it will all become a little easier to access. You need to go to http://community.borland.com, Register, then fill in a questionnaire before you can download anything. You should then be given a link to download the package from. It weighs in at about 8MB.

Don't install the Compiler yet, we'll cover that in the next section:

2) Setting-up the Compiler

This is the part where most new programmers will get unstuck. The instructions that come with the free Tools package are terse to say the least - not very helpful where you are unsure about how to set your 'Path Environment Variable'...

a) Install Compiler & ToolsFirst of all, decide where you are going to install this stuff. It'll take up to 50MB (depending on your file system - NTFS, FAT32, or FAT16) The default choice is 'C:\Borland\BCC55', and unless you have a good reason for putting it elsewhere, this is a good choice. Double clicking on the file you downloaded will take care of this part.

(If you decided NOT to install the package in C:\Borland\BCC55, substitute the full path to your chosen folder (eg. 'd:\borland') whenever I quote 'C:\Borland\BCC55' in these instructions...)

b) Configure CompilerThe installation package just copies files to your computer. You have to manually configure it to work on your system. First of all you need to add two config files to your C:\Borland\BCC55\bin directory, namely ilink32.cfg, and bcc32.cfg.

The file 'files/tutorials/bcc_config.exe' will automate this process for you, but only if you installed the tools to 'C:\Borland\BCC55\'. If you did not you will need to edit the above files manually to reflect your chosen install path, and then manually copy them into the 'bin' directory.)

c) Let Windows KnowYour compiler is now rockin', but you have to tell Windows about it. You do this by adding your 'bin' directory ('bin' for binary, or executable file...) to Windows' Path. The Path is a list of directories that Windows searches through when asked to run a command... Windows NT and Windows 95/98 differ here, so we'll break off to separate sections:

Windows NT/2000

In the Control Panel open the 'System' applet.

Go to the 'Environment' page.

Halfway down the page you will find a list of User Variables.

Click the 'path' variable.

In the section below, you can see two edit controls, 'Variable' and 'Value'. Make sure that the variable being displayed is 'Path'.

We need to add 'C:\Borland\BCC55\bin' to this. If there is already something there, type a semi-colon (;) at the end, then our installation path.

Windows 95/98/ME

Find the file 'Autoexec.bat' (if you only have one or more files called just Autoexec, then ours is the one with an icon that looks like a Cog wheel in a blue frame).

Right click the file, and choose 'Edit' from the pop-up context menu. A

t the very bottom of this file type, on it's own line, the following:PATH=%PATH%;C:\BORLAND\BCC55\BIN

Restart your machine, and you'll be ready to...

3) Configure your Text Editor

We are going to be using the text editor you downloaded in Step one, EditPlus, a great shareware editor. It is very good at interfacing with command line tools like our free compiler, even without much configuring. The following instructions are for Version 2, but Version 1 differs only very slightly...

Choose 'Tools' from the menu, then 'Configure User Tools'

Click 'Add Tool'

Name it BCC32 (The Compiler's chosen moniker), and browse to 'C:\Borland\BCC55\Bin\BCC32.exe'

Choose 'Filename' from the list of Arguments, and 'File's Directory' as the initial directory.

Make sure 'Capture Output' is ticked.

The text editor is now configured as a light-weight IDE. You can invoke the compiler on your text files by pressing Ctrl+1. If you get any error messages from the compiler, you can double click on it to jump to that line in your program.

If all goes well you should find an .exe file you can run in your source directory.

The Command Line Way...

The whole aim of this tutorial is to wean beginner programers away from expensive, commercial IDEs, and lead them to the powerful and FREE (if intimidating) world of command lines and open source software.

What you are doing with the text editor here is to get it to automate a few tasks for you. When you compile a .cpp file, say hello.cpp by pressing Ctrl+1 it's as if you were to type at a command prompt (sometimes called, erroneously, a DOS screen...):

That is, you run the program called bcc32, and you pass it the argumenthello.cpp. Clear and simple?

4) Testing, and the FAQ

You are now able to compile simple C++ programs by simply typing 'em in and pressing Ctrl+1. Try it with the following (This is standard C++, not the C that many 'C++' tutorials will teach you...):

Where to from here?

You will very quickly out grow this method of programming - one file programming is only really sufficient for learning purposes. You will need to learn about make files if you want to write larger programs while sticking to free tools. IDEs such as Microsoft Visual C++ can make things seem easier, but limit you to writing platform specific programs - i.e. Windows only. Also, because they hide the way they work from you, one often finds oneself stuck trying to second guess the Microsoft programmers... That said, if you just want to learn C++, an IDE sometimes makes starting out. I can heartily recomend Devcpp, a modern free IDE for Windows.

It is possible to write programs like the trivial example above, that will compile and run on any system that has a full C++ implementation (Windows, MacOS, BeOS, Linux, Unix...), and this is an approach that I would recommend. By using the leverage of libraries, like the C++ Standard, you can quickly create powerful, multi-platform code. If you need to write platform specific code (like responding to a mouse) you can put that code in a separate file.

That in mind, here are a few texts to get you started. These are books that I own myself, and that I found to be the most useful. The first is available free on my website, and will ready you for the other, more advanced books.

You can read, or download this whole book free. It's a really good introduction to C++, and takes you to quite an advanced level. The great thing about this book is that is deals with, and teaches the recent C++ standard, not just a whole bunch of old C constructs like many books do.

By itself, C++ does not know how to write to your screen, or open a file. These indispensable functions are performed by library functions. The C++ library adds to the C library, including an implementation of the STL. This book serves as an exellent tutorial and reference.

FAQ

I pressed Ctrl+1 to compile the program and I got an error message saying 'could not open ilink32'This is by far the most common message I get regarding the tutorial. If you get this, you did not follow step (2b) properly. Reread the instructions and try again.

Where is my program?Its in the directory where you saved the source code for your program... You may want to open a command prompt (aka DOS Window), and run your program from there so that you don't get the ole' My program ran in a DOS Window for a second but closed before I had a chance to see it error...

The End...

Well, that's all folks! Please feel free to send me some feedback. Aside from spelling and grammatical errors, I'm very interested to hear how you found the level of this tutorial. Did I labour simple points, but gloss over parts you found tricky? I'm aiming at those who're beginning to program in C++, so I do assume possession of good computer skills, and general smarts - but if you think that's you and my instructions are too hard (or easy), then please, let me know.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

Share

About the Author

Leon lives in Auckland, New Zealand - a city built amongst a dozen or so (hopefully) extinct volcanos. He ekes out a living there with contract work, and spends all his time thinking deeply about something or other. Despite good intentions, he is frequently late, and often gets in trouble for forgetting social appointments.

C++ is his favourite (computer) language, though recently he has spent most of his time writing web apps using PHP and PostgreSQL under Apache. He is very interested in improving MIQ - Machine intelligence, and playing with data compression...

He can be found at:
The Lost Continent of
http://www.lost.co.nz

Comments and Discussions

Hello .. Iam a university student in Indonesia, now we learn about C# and Borland C++, There is a generous people in this site want to help me, share me your code, and if you dont mind, teach me !!! our teacher it's very-very lazy to teach us, need your help all... thanx

On the Subject of IDE's I've been using a simpler editor called SciTe... I personally don't like it much but I dose the job I need it to do. I have also been using a better and free editor called chrome. which is a MASM32 Win Asembler editor but can be configured for other plat forms. My Questions:: Is there anybody out there that is familiar with chrome, know how to convert it to accept the borland C++ 5.5 compilor? I've been attempting to figure it out myself but if someone knows already I would apreciate the info

Hi thanks for this great tutorial.
Just wondering what to do when my project consists of xxxx.h and xxxx.cpp?
Can borland handle this?
Also should I try to learn about a newer compilers with p4 and/or amd athlon optimizations?
If so can you offer a suggestions?
I am new to programming but it has challenged me so much I will be studying extensevily...until the battle has been won

That should not be a problem, sure Borland can handle it!
The compiler does support the pentium chip and optimizing for it. Likely not the latest generations of the pentium chip (like Microsoft C++), but you have to ask yourself how big an impact those optimizations will have and also what most of your target users will have. If you are new to programming, do not worry about optimizations for now. You can always flip a compiler switch later and often the way you write your code will have far bigger impact.

Coff2omf.exe can convert a lib file from the Microsoft COFF format to OMF so that ilink32 can link against it. However, lib files come in two flavours: one just tells the linker what is inside the corresponding DLL and it actually links against the DLL. The other type contains OBJ files that you actually want to link into your EXE. If you use COEFF2OMF on that, you get an empty lib file and linking against that results in unresolved externals. So what do you do to fix that? How do you get teh OBJs (for which you dont have source code) into your Borland exe?

1) Use Visual Studio and create a Win32 DLL project. Add the LIB containing the OBJS as an extra dependency to the project (look under Project, Properties). Now add a .DEF file to the project add the following lines to it:EXPORTS
method1 (list the methods you want to use from Borland here one below another)
method2
method3
2) Now build the DLL in Visual Studio. Visual studio will create a DLL and a LIB.
3) Now use COFF2OMF on this new LIB and pass this lib to ilink32 to link against that. This will take care of all the unresolved externals, but your EXE will need the DLL present when it loads.

But it works!!!! Took me several hours to figure this out. On the internet there are several references to this problem, but nobody gave a workable solution.

This shows how to compile a resource file as well, link it in, as well as additional library files. The -v gives you debug information which you need if you want to debug your app using td32.exe.

The compiler is quite good and very compatible with Microsoft. I did find the following differences between it and VC6:
1) The FONT line for dialog boxes in a Microsoft produced .rc file contains an extra ",0x01" at the end of the line. brc32 gives an error about expecting a BEGIN here. Simply remove the extra ,0x01 and it will compile fine.
2) brc32 does not support certain types of ICO files and they disappear from your appplication when you run them. To get around this use icon files containing a single icon and make it a 32x32 with 256 color icon. Borland apparently does not like the XP or 16 million color icons. Not sure.
3) If you use the STL string class, having a static instance of it in your code will result in unresolved externals (delete (void*), __nullref, etc.). To work around this simply put the static strings inside a struct and new and use a pointer to that struct.

I am using the Borland compiler with the EditPlus "IDE" on a machine running XP PRO and have a problem when trying to build the libraries for wxWidgits (wxWindows). All seems to go well intil the makefile comes to the command line:

Notice that the /P option for TLIB is getting changed from 1024 to 512. I first thought I was running out of handles in the Virtual DOS Machine so I edited the config.nt file to change the FILES=20 line to FILES=99 and still get the error. Any ideas on what problim I am experiencing????

Does anyone have an example of an Borland C++ 5.5 Win32 program that uses "DialogBoxParam" to generate a Dialog as the programs main "window" ? I'm having trouble getting this "api" to work ( I keep getting "parameter mismatch" messages from bcc32 ) . Thanks......

Prompt the user for input file name, read the file and determine the number of alphanumeric characters, the number of words, the number of sentences in the file. To determine the number of sentences the number of periods (dots) should be counted (newlines and tabs should be disregarded). Allow the user to press any keys to return back to the main menu.

Prompt the user for the input and output file names, append the contents of one file to another. Allow the user to press any keys to return back to the main menu.

Prompt the user for input file name, word the user want to replace, and the substitute word. Open the file and replace all the occurrence of the user specified word by another word in the entire file. After all, tell the user how many replaces have been taken place. Allow the user to press any keys to return back to the main menu.

Exit the program.

the c plus plus program. how to write.

Implement a program which can perform the following actions:

Prompt the user for input file name, read the file and determine the number of alphanumeric characters, the number of words, the number of sentences in the file. To determine the number of sentences the number of periods (dots) should be counted (newlines and tabs should be disregarded). Allow the user to press any keys to return back to the main menu.

Prompt the user for the input and output file names, append the contents of on

Hi,
I have downloaded Borland's free compiler just for curiosity. Now, after few simple examples, I wanted to do something bigger. I can build and run console applications, but I have lot's of trouble with writing a win32 application. I am writing exactly as I wrote with VC++ 6.0 and I cannot make anything run - it cannot compile - WinMain is reported with bunch of errors. Can anyone help me with this?? Can you give me a link where I could find something about building generic win32 applications with borland free compiler, or someone can directly help me, telling me what to do ( just a source and cfg file would be nice ).
Thanks

VIDE is indeed free, and supports BCC quite nicely. It was the FIRST IDE
to support the free Borland compiler, and I think remains one of the best.
BCC support is not an add-on to the IDE - it is really supported.
It is very important, however, to read the specific installation instructions
for the Borland version, as VIDE also supports the GNU gcc compiler, and
you MUST tell VIDE which compiler you will be using. This is all spelled out
in the installation files.

VIDE: http://www.objectcentral.com/vide.htm

Also, there is some extra documentation about BCC 5.5 that is found at no
other sources that I know of, includeing full documentation on ALL the switches
for BCC and ILINK specifically written for BCC 5.5. These are available with
VIDE, or in fact at http://www.objectcentral.com/vide/help/videdoc/bcc32.html.

I also would highly recommend Helmut Pharo's site:
http://www.pharo.onlinehome.de/Bcc55.html
for more great tips on using BCC 5.5.

There will be a new release of VIDE within a week or so, so be sure to go
back and get the new version if you already have VIDE, or download it now.