================================= MACHINE SPECIFIC NOTES FOR INFORMIX-Client SDK 2.40.UC1 PRODUCT RELEASE C++ Interface Version 2.7 10-29-1999 ================================= Machine Specific Notes: ====================== 1. Calling HP aC++ from HP C ========================= When mixing C++ modules with C modules, usually the overall control of the program must be written in C++. In other words, the main() function must appear in some C++ module, rather than in a C module, and you must link using aCC (ANSI C++). The two exceptions to this rule are C++ programs and libraries (including HP-supplied libraries) without any global class objects containing constructors or destructors and C++ programs and libraries (including HP-supplied libraries) without static objects. Since most C++ programs use the HP aC++ run-time libraries, few programs meet these restrictions. Therefore, you can call a C++ module from a C module by following the points below, as well as the points in General Information When Calling Other Languages: a) To prevent a function name from being mangled, the function definition and all declarations used by the C++ code must use extern "C". b) The C programmer must generate a call to function _main as the first executable statement in main(). Object libraries require this as _main calls the static constructors to initialize the libraries' static data items. c) Member functions of classes in C++ are not callable from C. If a member function routine is needed, a non-member function in C++ can be called from C which in turn calls the member function. d) Since the C program cannot directly create or destroy C++ objects, it is the responsibility of the writer of the C++ class library to define interface routines that call constructors and destructors, and it is the responsibility of the C user to call these interface routines to create such objects before using them and to destroy them afterwards. e) The C user should not try to define an equivalent struct definition for the class definition in C++. The class definition may contain bookkeeping information that is not guaranteed to work on every architecture. All access to members should be done in the C++ module. The following example programs illustrate some of the above points, as well as reference parameters in the interface routine to the constructor. Calling HP aC++ from HP C: An Example ===================================== //************************************************** // C++ module that manipulates object obj. * //************************************************** #include <iostream.h> typedef class obj* obj_ptr; extern "C" void initialize_obj (obj_ptr& p); extern "C" void delete_obj (obj_ptr p); extern "C" void print_obj (obj_ptr p); struct obj { private: int x; public: obj() {x = 7;} friend void print_obj(obj_ptr p); }; // C interface routine to initialize an // object by calling the constructor. void initialize_obj(obj_ptr& p) { p = new obj; } // C interface routine to destroy an // object by calling the destructor. void delete_obj(obj_ptr p) { delete p; } // C interface routine to display // manipulating the object. void print_obj(obj_ptr p) { cout << "the value of object->x is " << p->x << "\n"; } Following is a C program that calls the C++ module to manipulate the object: /***************************************************/ /* C program to demonstrate an interface to the */ /* C++ module. Note that the application needs */ /* to be linked with the aCC driver. */ /***************************************************/ typedef struct obj* obj_ptr; main () { /* C++ object. Notice that none of the routines should try to manipulate the fields. */ obj_ptr f; /* The first executable statement needs to be a call to _main so that static objects will be created in libraries that have constructors defined. In this application, the stream library contains data elements that match the conditions. */ _main(); /* Initialize the data object. Notice taking the address of f is compatible with the C++ reference construct. */ initialize_obj(&f); /* Call the routine to manipulate the fields */ print_obj(f); /* Destroy the data object */ delete_obj(f); } Compiling and Running the Example Programs ========================================== To compile the example, enter the following commands: cc -c cfilename.c aCC -c C++filename.C aCC -o executable cfilename.o C++filename.o CAUTION ======= During the linking phase, the aCC driver program performs several functions to support the C++ class mechanism. Linking programs that use classes with the C compiler driver cc leads to unpredictable results at run time. 2. Creating a Shared Library ========================= To create a shared library from one or more object files, use the -b option at link time. (The object files must have been compiled with +z or +Z.) The -b option creates a shared library rather than an executable file. CAUTION ======= You must use the aCC command to create a C++ shared library. This is because the aCC command ensures that any static constructors and destructors in the shared library are executed at the appropriate times. Example ======= aCC -b -o util.sl util.o This example links util.o and creates the shared library util.sl. For shared library support, environment variable SHLIB_PATH needs to be set to include the $INFORMIXDIR/lib, $INFORMIXDIR/lib/c++ and $INFORMIXDIR/lib/esql directories where CPP shared libraries are installed. For C Shell, use setenv SHLIB_PATH $INFORMIXDIR/lib:$INFORMIXDIR/lib/c++:$INFORMIXDIR/lib/ esql:$SHLIB_PATH For Bourne Shell, use SHLIB_PATH=$INFORMIXDIR/lib:$INFORMIXDIR/lib/c++:$INFORMIXDIR/lib/esql: $SHLIB_PATH export SHLIB_PATH 4. This product was built and tested on HPUX 10.20 with the following patches installed. 1020S800 5. ClientSDK 2.40 is the last version supported on HP-UX 10.20. Future releases will be available only on HPUX 11.0 and higher versions. ================================= MACHINE SPECIFIC NOTES FOR INFORMIX-Client SDK 2.40.UC1 PRODUCT RELEASE INFORMIX-ESQL/C Version 9.30.UC1 10-29-1999 ================================= Machine Specific Notes: ======================= 1. If "undefined symbols" errors occur when linking your application, it could be because your machine does not have /usr/lib/libV3.a installed. This is part of the HP PROG-AUX package. It may not be installed on your machine if you are using an HP S700 run-time only system or an HP S800 8 user runtime system. 2. ESQL/C product libraries are supported as both static and shared libraries. The 'esql' script is changed to use the shared or static libraries. By default the script uses shared libraries. To use static libraries, the 'esql' script can be invoked as esql -static During execution of ESQL/C program, compiled with shared library you need to remember two points: A. Environment Variable SHLIB_PATH. Environment Variable SHLIB_PATH should be set to include $INFORMIXDIR/lib and $INFORMIXDIR/lib/esql. During runtime of the executable, dynamic loader will look for this path for Informix ESQL/C shared libraries. SHLIB_PATH=$INFORMIXDIR/lib:$INFORMIXDIR/lib/esql:$SHLIB_PATH export SHLIB_PATH (for Bourne or Korn Shell) setenv SHLIB_PATH $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql:$SHLIB_PATH (for C Shell) B. For the application, where user builds shared object by combining their own code with Informix shared libraries and later use a generic module to load this shared object, should use bind flag "BIND_DEFERRED" exclusively. HPUX 10.0x supports shl_load() function to load such shared object from user program. Example: shl_load("libos.sl",BIND_DEFERRED,0) ; to load libos.sl into memory. ESQL/C applications using previous versions of Informix ESQL/C libraries may need to be recompiled and/or relinked to work with this version of product. 3. The thread safe ESQL/C libraries require DCE library support and the following packages are to be installed: DCE-Core B.10.01 HP DCE/9000 Core client Software Since DCE on HP mandates an ANSI compile, the esql script has been modified to compile with the HP ANSI flags "-Ae -D_HPUX_SOURCE". If for some reason you need to compile the .c file, these flags need to be used to avoid ANSI compile errors. To execute thread safe ESQL/C programs, make sure to set the THREADLIB environment variable to dce. For example THREADLIB=dce; export THREADLIB (for Bourne or Korn Shell) setenv THREADLIB dce (for C Shell) At present, this feature is supported for the OnLine engine and the following protocol only: Berkeley sockets using TCP/IP Applications that have not been compiled with the -thread option cannot be linked with applications that have been compiled with the -thread option. To do so, compile all applications with the -thread option. 4. TERMINFO is NOT supported on this platform. 5. This product was built and tested on HPUX 10.20 with the following patches installed. 1020S800 6. ClientSDK 2.40 is the last version supported on HP-UX 10.20. Future releases will be available only on HPUX 11.0 and higher versions. ================================= MACHINE SPECIFIC NOTES FOR INFORMIX-Client SDK 2.40.UC1 PRODUCT RELEASE GLS API Version 3.10 10-29-1999 ================================= This product was built and tested on HPUX 10.20. Machine Specific Notes: ======================= 1. ClientSDK 2.40 is the last version supported on HP-UX 10.20. Future releases will be available only on HPUX 11.0 and higher versions. ================================= MACHINE SPECIFIC NOTES FOR INFORMIX-Client SDK 2.40.UC1 PRODUCT RELEASE ODBC for SQL Version 3.3 10-29-1999 ================================= Machine Specific Notes: ======================= 1. For shared library support, environment variable SHLIB_PATH needs to be set to include the $INFORMIXDIR/lib/cli directories where CLI shared libraries are installed. For C Shell, use setenv SHLIB_PATH $INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql:$SHLIB_PATH For Bourne Shell, use SHLIB_PATH=$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql:$SHLIB_PATH export SHLIB_PATH 2. The thread safe CLI libraries are supported for the current release. To use thread safe libraries, the 'cc' compiler can be invoked as cc -g -o <executable-name> <filename.o> -lthcli 3. This product was built and tested on HPUX 10.20 with the following patches installed. 1020S800 4. ClientSDK 2.40 is the last version supported on HP-UX 10.20. Future releases will be available only on HPUX 11.0 and higher versions. ==========================================