5.2 MEX-files on the HP 9000/700

MEX-files on the HP 9000/700 platforms are implemented as shared libraries. In order to create a shared library, the linker requires code which is position independent. Unfortunately, the C compiler, which is bundled with HP-UX 9.0x does not support the position-independent option. The error message you receive when trying to compile with the bundled compiler is

cc: warning 422: Unknown option "c" ignored.
ld: DP-Relative Code in file <MEX-file name>.o - Shared 
Library must be Position-Independent.
To determine if you have the bundled compiler, type the command

what `which cc`
(note that the single quotes are backquotes). If the result says "HPC (Bundled) Compiler", then you have the bundled compiler.

There are two possible solutions. The recommended solution is to upgrade your C compiler by adding to it the C/ANSI C Developer's Toolkit, available from Hewlett Packard. This version of the C compiler supports position-independent code generation.

The second possible alternative is to use the GNU C compiler. We have not tested gcc extensively with cmex, but have found that we have been able to compile and run the standard MathWorks MEX-files such as yprime.c, etc. To compile with gcc, you need to either specify certain command line options, as follows:

cmex <MEX-file name>.c CC=gcc \
CFLAGS_REQUIRED="-fpic -DMATLAB_MEX_FILE"
or, you can modify the cmex script as follows:

change line 495 from

CC = 'cc'
to

CC = 'gcc'
and change line 560 from

CFLAGS_REQUIRED="+z $CFLAGS_REQUIRED"
to

CFLAGS_REQUIRED="-fpic $CFLAGS_REQUIRED"

(c) Copyright 1994 by The MathWorks, Inc.