Compile Options - Maple Help

define_external(COMPILE_OPTIONS)

get and set C compiler options for generating wrappers used by define_external

 Calling Sequence define_external(COMPILE_OPTIONS)

Description

 • When the WRAPPER option is used with define_external, a C file is created, compiled and linked into Maple.  This new library, called a wrapper library, contains the code necessary to translate Maple data types into data types recognized by C programs.
 • To compile the wrapper library a compiler must be installed and recognized by the system.  In most cases, if the compiler is in the system PATH, and all associated environment variables are set, then the wrapper generation and compilation will work "out of the box".  Maple is preprogrammed to use the vendor supplied C compiler to compile most wrappers on most platforms. To use a non-standard compiler, alternate version of a compiler, or custom setup, change the COMPILE_OPTIONS Record.
 • The COMPILE_OPTIONS argument by itself in a call to define_external returns a Record module containing default or current compile and link settings used for building the generated wrapper library.  These options are globally settable by changing any of the module exports, or locally by passing the equation moduleExportName=value as an argument to define_external.
 • The compile and link commands are assembled by calling the COMPILE_COMMAND and LINK_COMMAND procedures defined in the COMPILE_OPTIONS Record.  These procedures make use of the other definitions in the COMPILE_OPTIONS Record to formulate a command string that is executed by the ssystem command.
 • The COMPILE_OPTIONS available are:

 • To view the generated compiler and linker commands when executing define_external, set infolevel to 3 or higher.

Examples

The following example shows how to set up the GNU compiler on a machine running Solaris.  The gcc compiler requires a space between -o and the object name.  Modifying the COBJ_FLAG allows this to be easily done.

 > $p≔\mathrm{define_external}\left('\mathrm{COMPILE_OPTIONS}'\right):$
 > $p\left[\mathrm{COMPILER}\right]≔"gcc"$
 ${{p}}_{{\mathrm{COMPILER}}}{≔}{"gcc"}$ (1)
 > $p\left[\mathrm{COBJ_FLAG}\right]≔"-o"$
 ${{p}}_{{\mathrm{COBJ_FLAG}}}{≔}{"-o"}$ (2)

Subsequently a command like the following will use the new options.

 > $\mathrm{define_external}\left('\mathrm{mat_mult}','\mathrm{WRAPPER}','\mathrm{LIB}'="libtest.so"\right)$