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

The following instructions are for use with a recent versions of ACE+TAO. If you are using TAO 1.1 please use these instructions instead.

  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 and installed ACE+TAO into a directory called C:\ACETAO. Please note that "installed" means having run

    make -f Makefile.bor -DINSTALL_DIR=C:\ACETAO install
    at the completion of your build, as shown in the build instructions. The C:\ACETAO directory should contain sub-directories called bin, lib and include.

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

  3. In your .cpp files, replace occurrences of

    #include <vcl.h>
    #pragma hdrstop
    with
    #include <tao/corba.h>
    #pragma hdrstop

  4. 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.

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

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

  7. Add the following directory to the include path:

    C:\ACETAO\include
    Tip: By entering your paths prefixed with "\\?\", such as \\?\C:\ACETAO\include, you may be able to prevent C++Builder from automatically changing them to relative paths when you close the Project Options dialog.

  8. Add this directory to the library path:

    C:\ACETAO\lib

  9. Add the following conditional defines:

    ACE_HAS_VCL=1
    This define causes the TAO header files to include vcl.h for you automatically.

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

  11. Close the Project Options dialog.

  12. 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
    You may add other TAO libraries as required for the CORBA Services. For example, to use the Naming service you would add:
    TAO_CosNaming_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 cp32mti.lib

  13. Build your application.

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

    -Wb,pch_include=tao/corba.h
    so that the generated source files will use the correct pre-compiled header file.

  In this section

 Introduction 

 Obtaining TAO 

 Building TAO 

 Using TAO 

 Patches 

 Support 

 Feedback 


Copyright © 2000-2002 Tenermerx Pty Ltd