Using Borland's Command Line Tools |
|||||||||
|
|||||||||
|
Zip files containing the code from this page can be found here: [C++ Language ZIP File] [C Language ZIP File] Most programs are built with more than one source file. An example is the two source and one header file below where main.cpp calls a function in add.cpp and uses the result.
// ----TestAdd.CPP-----
#include <iostream>
#include "add.h"
using namespace std;
int main()
{
cout << "5 + 3 equals " << Add(5, 3) << endl;
return 0;
}
// -------Add.CPP------
#include "add.h"
int Add(int x, int y)
{
return x + y;
}
// --------Add.H--------
#ifndef ADD_H
#define ADD_H
int Add(int x, int y);
#endif
// --------------------
To build a multi-file project just list the files on the command line.
The base name of the executable will be the same as that of the first
(leftmost) file. The command below will build the program
TestAdd.EXE.
bcc32 -WCR testadd addYou can take advantage of the fact that the compiler understands some file extensions. For instance, pretend that you had made a change to testadd.cpp above but have not changed add.cpp. You do not need to rebuild add.obj because it is still correct. A command that would build the program but not take the time to compile add.cpp again would be: bcc32 -WCR testadd add.objNote: The compiler understands the significance of the extensions .C, .CPP, .LIB, .OBJ and .ASM If a file name is given without an extension is assumed to have an extension of .CPP |
|||||||||
| [Next Page: Static Libraries] | |||||||||