Home > Programming > CORBA > TAO with C++Builder > Using TAO >
Setting up a VCL Application to use TAO 1.1

  1. These instructions assume you want to create an executable that is dynamically linked to TAO. To do this you need to have built a release version of VCL-compatible dynamically linked TAO libraries. They also assume that you have unpacked the ACE+TAO source kit into a directory called C:\ACE_wrappers.

  2. Create a new application by going File|New Application.

  3. Create a new header file to use for pre-compiled headers, calling it something like pch.h. In it, put:

    #ifndef INCLUDE_PCH_H
    #define INCLUDE_PCH_H
       
    #include <vcl.h>
       
    // We must disable this warning here since
    // the IDE does not seem to like having both
    // it and -w-rvl (Function should return a
    // value) specified in the CFLAG1 variable.
    #pragma option push -w-ccc
    
    #include <tao/corba.h>
    
    #pragma option pop
    
    #endif // INCLUDE_PCH_H
    
    You may add other header files that you wish to be pre-compiled.

  4. In your .cpp files, replace occurrences of

    #include <vcl.h>
    with
    #include "pch.h"

  5. TAO uses the ACE library, so you need to initialise ACE from your program. To do this you can add calls to ACE::init and ACE::fini from startup and cleanup functions:

    #pragma package(smart_init)
    
    void ace_init(void)
    {
    #pragma startup ace_init
      ACE::init();
    }
    
    void ace_fini(void)
    {
    #pragma exit ace_fini
      ACE::fini();
    }
    
    WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
      // ...
    }
    For VCL applications it is important that you have the line
    #pragma package(smart_init)
    
    so that the ACE::init and ACE::fini calls occur before and after the VCL cleanup and initialisation respectively.

  6. Go to Project|Options, then to the Linker page and make sure that "Use dynamic RTL" is checked.

  7. Still in the Project Options dialog, go to the Directories/Conditionals page.

  8. Add the following directories to the include path:

    C:\ACE_wrappers
    C:\ACE_wrappers\TAO
    C:\ACE_wrappers\TAO\orbsvcs
    Tip: By entering your paths prefixed with "\\?\", such as \\?\C:\ACE_wrappers, you can prevent C++Builder from automatically changing them to relative paths when you close the Project Options dialog.

  9. Add this directory to the library path:

    C:\ACE_wrappers\bin\Dynamic\Release\Pascal

  10. Add these conditional defines:

    WIN32
    ACE_HAS_DLL=1
    TAO_HAS_DLL=1
    TAO_ORBSVCS_HAS_DLL=1
    ACE_USE_RCSID=0

  11. Switch to the Compiler page, enable "selected" warnings only, and then disable these warnings:

    Function should return a value (-wrvl)
    Parameter is never used (-wpar)
    Unreachable code (-wrch)

  12. Still on the Compiler page, now in the Pre-compiled Headers section, change the file name to something like myapp.csm and stop after pch.h.

  13. Close the Project Options dialog.

  14. Go to Project|View Makefile (for C++Builder 5 Project|Edit Option Source) and add the following libraries to the end of the SPARELIBS line:

    ACE_bp.lib TAO_bp.lib ORBSVCS_bp.lib
    You should also make sure that the LIBRARIES variable is on the ALLLIB line. For example, with C++Builder 4:
    ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib

  15. Build your application.

  16. When compiling IDL files (using tao_idl) add the command line option

    -Wb,pch_include=pch.h
    so that the generated source files will use your pre-compiled header file.

  In this section

 Introduction 

 Obtaining TAO 

 Building TAO 

 Using TAO 

 Patches 

 Support 

 Feedback 


Copyright © 2000-2002 Tenermerx Pty Ltd