Using Borland's Command Line Tools
Page 2: Multi-File Programs

Installation, First Use Multi-File Programs
Static Libraries Static Linked and Dynamic Linked
Make Files [1],  [2],  [3],  [4]  [Summary] Create and Use a DLL
Resource Files [1]


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 add
You 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.obj
Note: 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]

:: Main | Search | Site Map
 
:: Algorithms & Code
:: Assembly & Low Level
:: Borland/CodeGear
:: C & C++
:: CGI
:: CDROM Info
:: COM/DCOM/CORBA
:: Communications
:: Compression
:: Cryptography
:: File Formats
:: General Software
:: Games & Graphics
:: Hardware
:: HTML, Web Development
:: Linux/Unix/BSD
:: Microsoft
:: Miscellaneous
:: Neural Nets
:: New Links
:: Programming Articles
:: Programming Languages
:: Protocols
:: Sfwe Publications
:: Sfwe Sellers
:: Std Template Lib/STL
:: Tutorials, Refs: C/C++
:: Tutorials, Refs: Other
:: Utilities & Tools
:: XML & XHTML
:: Windows, Win32
:: 8051 & Embedded
  Programming Pages 
::  #1 #2 #3 #4 #5 #6 #7
Valid HTML 4.01 Strict