HP 3000 Manuals

Building DCE Programs [ DCE for the HP 3000 ] MPE/iX 5.0 Express III Documentation


DCE for the HP 3000

Building DCE Programs 

Header Files 

In addition to the standard POSIX libraries and HP C/XL functions, you
may have to include the DCE header files, which can be found in the
/usr/include/dce directory.  If your C applications use Try/Catch for
exception handling, you should include the following statement in the C
programs:

     #include <dce/pthread_exc.h>

There are no MPE/iX equivalent libraries for /usr/lib/libbb.a or
/usr/lib/libc_r.a.  The reentrant functions that are defined in MPE/iX
and the thread-safe wrapper functions are in /usr/lib/libdce.a.

MPE/iX does not have the file strings.h.  The HP-UX strings.h includes
string.h, sys/stdsyms.h and some definitions that are strictly for C++
and HP-UX.

Compiler Flags 

When compiling DCE applications using ANSI C under the MPE CI, set the
following compiler switches:

     -D_POSIX_SOURCE -D_MPEXL_SOURCE -D_SOCKET_SOURCE -D_REENTRANT -Aa

When compiling under the MPE POSIX shell, you need the above flags except
for the -Aa optoin.  If -Aa is set, /bin/c89 displays a large amount of
error messages (by definiton, the POSIX environment always uses the ANSI
C compiler).

Link Options 

The MPE/iX Shared Global feature allows a DCE library to be placed in an
executable library (XL); because, Shared Globals allow global data to be
shared within a process between executable libraries and DCE
applications.  Since DCE applications must be POSIX C compliant, the
POSIX C library (/lib/libc.a) are added as a separate SOM in the DCEXL.
Code and data entry points in this SOM are both revealed.  Because DCEXL
contains POSIX C routines, applications do not require the -lc
specification in the library search list during the link pass.

There are two ways to link a DCE program on the DCE/3000 version A.01.12.

   *   Archive linking - link with libdce.a.  This is the traditional way
       to link DCE applications.  The DCE applications must specify the
       following libraries from the the MPE POSIX shell:

            -ldce -lsocket -lsvipc -lm  -lc 

   *   Shared linking - link with DCEXL.HPDCE.SYS. The DCE applications
       do not have to specify "-ldce" in the library search list.  Since
       POSIX C is also included in the DCEXL, the libraries to be linked
       may only contain:

            -lsocket -lsvipc -lm 

       There will be unsatisfied data and code symbols from the above
       linking.  In order to resolve those symbols at load time, you must
       add DCEXL before othdxl in the XL list before running the program.
       This can be done in LINKEDIT:

            LinkEd> altprog myprog;;xl=dcexl.hpdce.sys, othdxl.threads.sys 

Refer to the Makefile examples in the next two sections for complete
compile and link scripts.

Because the DCE library is large in size, the above link options make a
large difference in the amount of disk space a DCE application will take.
However, if DCE applications need to use the shared library, then special
attention should be paid to the code and data symbol binding rules at
load time.  For application developer's that want a better understanding
of Shared Globals functionality, refer to two articles in the MPE/iX 
Communicator 3000; the "MPE/iX Shared Globals Technical Overview" and
"POSIX Libraries in XLs" articles.

Because DCEXL contains the POSIX C library as a separate SOM, a DCE
application with a non-POSIX compliant library should specify the
non-POSIX compliant library after the DCEXL and the othdxl in the XL
list.  This is because the code symbol resolution is uni-directional and
forward bounded; therefore, the non-POSIX compliant library will not see
the symbols in the DCEXL library.

Unresolved Externals 

When porting applications from a unix environment to MPE/iX, you may
receive unresolved external errors during a compile, link, or run phase.
It is likely that the unresolved externals are not part of the POSIX.1
standard.  To find out if a function is defined in the POSIX environment,
look at the manpage for that function on a UNIX system.  At the bottom of
the manpage, there is a section titled STANDARD CONFORMANCE, which lists
the function name and the standard it conforms to.  If the manpage does
not have POSIX.1 listed as one of the standards then that function is not
part of the MPE/iX Posix Environment.  To get around this porting issue,
you may have to write a routine to emulate the functionality for the
unresolved external.

MPE/iX Makefile Example -Archive Linking 

The following is an MPE/iX makefile example.

     #
     # (c) Copyright 1992, 1993 Hewlett-Packard Co.
     #
     # @(#)HP DCE/3000 1.0.2
     # @(#)Module: Makefile $Revision:1.1.7.2 $
     # $Date:1993/07/08 00:06:21$
     # Makefile modified for use on an HP 3000.
     #

     DEBUG           =
     INCENV          = -I. -I/usr/include
     ANSI_FLAGS      = -D_POSIX_SOURCE
     HP_FLAGS        = -D_REENTRANT -D_MPEXL_SOURCE -D_SOCKET_SOURCE

     CFLAGS          = ${ANSI_FLAGS} ${DEBUG} ${HP_FLAGS} ${INCENV}
     LDFLAGS         =
     LIBS            = -ldce -lsocket -lsvipc -lm -lc

     PROGRAMS        = sleeper_server sleeper_client
     server_OFILES   = sleeper_sstub.o manager.o server.o
     client_OFILES   = sleeper_cstub.o client.o

     IDLFLAGS        = -keep c_source ${INCENV}
     IDLFILES        = sleeper.idl
     IDLGEN          = sleeper.h sleeper_*stub.c sleeper_*aux.c
     IDL             = /SYS/HPBIN/SH idl

     all:            objects ${PROGRAMS}
     objects:        ${server_OFILES} ${client_OFILES}
     fresh:          clean all

     clean:;
       rm -f ${server_OFILES} ${client_OFILES} ${PROGRAMS} ${IDLGEN}

     clobber:        clean
       rm -f a.out core ERRS make.out *~

     sleeper_server: ${server_OFILES}
       $(CC) ${LDFLAGS} ${server_OFILES} ${LIBS} -o $@
       mv -f sleeper_server /SYS/PUB/SLEEPSRV
       callci linkedit \"altprog sleepsrv.pub.sys\;xl='othdxl.threads.sys'\"
       mv -f /SYS/PUB/SLEEPSRV sleeper_srver

     sleeper_client: ${client_OFILES}
       $(CC) ${LDFLAGS} ${client_OFILES} ${LIBS} -o $@
       mv -f sleeper_client /SYS/PUB/SLEEPCLT
       callci linkedit \"altprog sleepclt.pub.sys\;xl='othdxl.threads.sys'\"
       mv -f /SYS/PUB/SLEEPCLT sleeper_client

     sleeper_cstub.c sleeper_sstub.c sleeper.h:      ${IDLFILES}
       $(IDL) ${IDLFLAGS} ${IDLFILES}

     sleeper_cstub.o sleeper_sstub.o manager.o server.o client.o: sleeper.h
     manager.o server.o client.o: common.h

MPE/iX Makefile Example - Shared Linking 

The following is an MPE/iX makefile example.

     #
     # (c) Copyright 1992, 1993 Hewlett-Packard Co.
     #
     # @(#)HP DCE/3000 1.0.2
     # @(#)Module: Makefile $Revision:1.1.7.2 $
     # $Date:1993/07/08 00:06:21$
     # Makefile modified for use on an HP 3000.
     #

     DEBUG           =
     INCENV          = -I. -I/usr/include
     ANSI_FLAGS      = -D_POSIX_SOURCE
     HP_FLAGS        = -D_REENTRANT -D_MPEXL_SOURCE -D_SOCKET_SOURCE

     CFLAGS          = ${ANSI_FLAGS} ${DEBUG} ${HP_FLAGS} ${INCENV}
     LDFLAGS         =
     LIBS            = -lsocket -lsvipc -lm

     PROGRAMS        = sleeper_server sleeper_client
     server_OFILES   = sleeper_sstub.o manager.o server.o
     client_OFILES   = sleeper_cstub.o client.o

     IDLFLAGS        = -keep c_source ${INCENV}
     IDLFILES        = sleeper.idl
     IDLGEN          = sleeper.h sleeper_*stub.c sleeper_*aux.c
     IDL             = /SYS/HPBIN/SH idl

     all:            objects ${PROGRAMS}
     objects:        ${server_OFILES} ${client_OFILES}
     fresh:          clean all

     clean:;
       rm -f ${server_OFILES} ${client_OFILES} ${PROGRAMS} ${IDLGEN}

     clobber:        clean
       rm -f a.out core ERRS make.out *~

     sleeper_server: ${server_OFILES}
       $(CC) ${LDFLAGS} ${server_OFILES} ${LIBS} -o $@
       mv -f sleeper_server /SYS/PUB/SLEEPSRV
       callci linkedit \"altprog sleepsrv.pub.sys\;xl='dcexl.hpdce.sys, othdxl.threads.sys'\"
       mv -f /SYS/PUB/SLEEPSRV sleeper_srver

     sleeper_client: ${client_OFILES}
       $(CC) ${LDFLAGS} ${client_OFILES} ${LIBS} -o $@
       mv -f sleeper_client /SYS/PUB/SLEEPCLT
       callci linkedit \"altprog sleepclt.pub.sys\;xl='dcexl.hpdce.sys, othdxl.threads.sys'\"
       mv -f /SYS/PUB/SLEEPCLT sleeper_client

     sleeper_cstub.c sleeper_sstub.c sleeper.h:      ${IDLFILES}
       $(IDL) ${IDLFLAGS} ${IDLFILES}

     sleeper_cstub.o sleeper_sstub.o manager.o server.o client.o: sleeper.h
     manager.o server.o client.o: common.h

HP-UX Makefile Example 

The following is an HP-UX makefile example.

     #
     # (c) Copyright 1992, 1993 Hewlett-Packard Co.
     #
     # @(#)HP DCE/9000 1.0.2
     # @(#)Module: Makefile $Revision: 1.1.7.2 $
     # $Date: 1993/07/08 00:06:21$
     # Makefile for use with an HP 9000.
     #

     DEBUG           = -g
     INCENV          = -I. -I/usr/include/reentrant
     ANSI_FLAGS      = -Aa -D_POSIX_SOURCE
     HP_FLAGS        = -D_REENTRANT -DTRACING

     CFLAGS          = ${ANSI_FLAGS} ${DEBUG} ${HP_FLAGS} ${INCENV}
     LDFLAGS         = ${DEBUG} -Wl, -a, archive
     LIBS            = -lbb -ldce -lm -lc_r

     PROGRAMS        = sleeper_server sleeper_client
     server_OFILES   = sleeper_sstub.o manager.o server.o
     client_OFILES   = sleeper_cstub.o client.o

     IDLFLAGS        = -keep c_source ${INCENV}
     IDLFILES        = sleeper.idl
     IDLGEN          = sleeper.h sleeper_*stub.c sleeper_*aux.c
     IDL             = idl

     all:            objects ${PROGRAMS}
     objects:        ${server_OFILES} ${client_OFILES}
     fresh:          clean all

     clean:;
       rm -f ${server_OFILES} ${client_OFILES} ${PROGRAMS} ${IDLGEN}

     clobber:        clean
       rm -f a.out core ERRS make.out *~

     sleeper_server: ${server_OFILES}
       $(CC) ${LDFLAGS} ${server_OFILES} ${LIBS} -o $@

     sleeper_client: ${client_OFILES}
       $(CC) ${LDFLAGS} ${client_OFILES} ${LIBS} -o $@

     sleeper_cstub.c sleeper_sstub.c sleeper.h:      ${IDLFILES}
       $(IDL) ${IDLFLAGS} ${IDLFILES}

     sleeper_cstub.o sleeper_sstub.o manager.o server.o client.o: sleeper.h
     manager.o server.o client.o: common.h



MPE/iX 5.0 Express III Documentation