Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Borland C++ Compiler

Status
Not open for further replies.

Newbie2PL

Technical User
Jul 25, 2001
7
CA
Hello
I am completely new and unfamiliar with programming but want to learn now. I did manage to make the "hello world" program work in Java 2. But I want to start with C.
I downloaded the Borland Compiler 5.5 but don't know where to start creating code. Would I use notepad or word for this? I want to make sure that following steps in a tutorial does not mess up my system too. Please help me take the first few steps down this path to programming in C. I need really basic guidance.
Thanks very much.
 
use notepad, compille with bcc, link with tlink John Fill
1c.bmp


ivfmd@mail.md
 
Thanks very much John!!! Now I can roll up my sleeves and get busy!
 
Hello
I have downloaded the Borland C++ compiler and I am following an online tutorial. I plan to try to learn C and C++ starting today! Here is the basic program and the instructions given. I have saved the file as .cpp. I have managed to do the "Hello world" in Java 2 some time ago. I seem to remember that the file name had to have " " around it. John said above "use notepad, compile with bcc, link with tlink". How do you compile and how do you use tlink (or is it ilink?)? When I try to open either .exe file they just disappear in a blink of an eye. They look like DOS dialogue boxes. I'm stuck.
Will you please give me a blow by blow as to how to get this first simple program running using BCC? I'd really appreciate it. Thanks!

#include <iostream.h>
int main()
{
cout<<&quot;HEY, you, I'm alive! Oh, and Hello World!&quot;;
return 0;
}

&quot;You can try out this program if you want, just cut and paste it into the IDE of a compiler such as DJGPP, or save it to a file ending with a .cpp extension, and use a command-line compiler to compile and link it.&quot;

 
C++Builder includes BCC32.EXE, the Borland C++ command-line compiler.

Command-line compiler syntax
The syntax for BCC32 is:
BCC32 [option [option...]] filename [filename...]
Where:
Items enclosed in brackets are optional.
option refers to the command-line options.
filename refers to the source-code files you want to compile.
To see a list of the commonly used compiler options, type BCC32 at the command line (without any options or file names), then press ENTER. This list displays the options that are enabled by default.

The command-line compiler name, each option, and the file names must all be separated by at least one space. Precede each option by either a hyphen (-) or a forward slash (/). For example:

BCC32 -Ic:\code\hfiles

Options and file names entered on the command line override settings in configuration files.

You can use BCC32 to send .OBJ files to ILINK32 or .ASM files to TASM32 (if you have TASM32 installed on your machine).

Default settings
BCC32.EXE has specific options that are on by default. To turn off a default option or to override options in a configuration file, follow the option with a minus (-) sign.

Files with the .CPP extension compile as C++ files. Files with a .C extension, with no extension, or with extensions other than .CPP, .OBJ, .LIB, or .ASM compile as C files.
The compiler tries to link with a module-definition file with the same name as the executable.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Whew! OK...first off, &quot;overriding options in a configuation file hopefully does not refer to config.sys???

Next, I still don't understand how to use this.
 
C++ compile

(Command-line switch = -P)

Is this the explanation? Please show me exactly how to handle getting that little program in the previous post to run. Thanks! Do you smell the smoke burning here? LOL

The -P command-line option causes the compiler to compile all source files as C++ files, regardless of their extension. Use -P- to compile all .CPP files as C++ source files and all other files as C source files.

The command-line option -Pext causes the compiler to compile all source files as C++ files and it changes the default extension to whatever you specify with ext. This option is provided because some programmers use different extensions as their default extension for C++ code.

The option -P-ext compiles files based on their extension (.CPP compiles to C++, all other extensions compile to C) and sets the default extension (other than .CPP).
 
Hi

Since you asked for just BASIC guidance :)...
If you haven't got to run the above program yet, type:
bcc32 Filename.cpp
at the command prompt from the bin directory. Include path if the file is not in the Bin directory. If it has a C extension it will get compiled as a C program, if it has a CPP extension it will get compiled as a C++ program, and then automatically get linked too, as per the default options (which are absolutely fine).

However before this make sure that you make the two configuration files (no they are NOT referring to the config.sys): bcc32.cfg and [ignore]ilink32.cfg[/ignore] in the bin directory. You can use notepad or any textfile editor to do this. Just make sure they have the extension .cfg and NOT .txt.
Type in the following inside bcc32.cfg:
-I&quot;Path to Include folder&quot; ...(Example: -I&quot;C:\Borland\BCC5\Include&quot;)
-L&quot;Path to Library folder&quot;
-n&quot;Path to Output folder&quot; ...(if u don't include this line the output files be in the bin folder)
and the following inside [ignore]ilink32.cfg[/ignore]:
-L&quot;Path to Library folder&quot;
You may add other options as per your requirements (but for the moment just forget other options, if you are not sure.)

Lastly, insert a
getch();
in the main() before
return(0);
This will make the program wait for you to press a key before it gets terminated. You may have to include stdio.h or conio.h.

And as a passing thought since you have used Java, if you have TextPad, its a nice option (better than Notepad) for writing down your programs and automating the compiling and linking too. But if you don't have it just forget it!!!

Hope this helps. :)

Bye.
Ankan. Please do correct me if I am wrong. :)
 
Thanks Ankan!!!
I can't wait to go home tonight to try this! I appreciate your help. If I can get that to go, then I just have to learn ALL the code right? LOL
 
Whew!
I got it to work! Thanks very much!!!!!
I encountered two things:
I had to use getchar instead of getch (looked in glossary)
and
the -n&quot;Path to Output folder&quot; caused some problems...but maybe my fault
I created an Output folder in c:\borland\bcc55\bin
but it gave error messages.
Thank you SO much Ankan. I better find out how to set up an output folder so I cannot cause damage and also organize my programs.
Could you shed some more light on this sometime please? Thank you again and again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top