11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.2 Using Compiled Code in Maple • 309LIB This names the library which contains the external function to call.This option must be specified in every call to define_external.LIBS This specifies other libraries that need to be linked with the wrapperlibrary to resolve all external symbols. Use an expression sequenceto specify more than one library, for example, LIBS=("/usr/local/maple/extern/lib/libtest.so","/users/jdoe/libdoe.so").SYS_LIBS This specifies system libraries to link with the wrapper libraryto resolve all external symbols. Use an expression sequence tospecify more than one library, for example, LIBS=("-lc","-lm").EXPORT_FLAG This flag is used in combination with the FUNCTIONoption to name the function to be exported from the shared library.This is unassigned or set to NULL on platforms that export all symbolsby default.FUNCTION This is the name of the external function defined in thewrapper library. The system generates a FUNCTION name if this is leftunassigned or set to NULL.LINK_COMMAND This is set to the procedure that generates thelinker command. The procedure must return a string. Set this to NULLif the compile command also does the linking.A common use of these options as parameters to define_externalwith a standard compiler would be to specify the filename. For example,the following generates a wrapper file named “foo.c”.> f := define_external(‘myfunc‘,‘WRAPPER‘,‘FILE‘="foo",‘LIB‘=> "mylib.dll"):To use a non-standard compiler or to alter compile flags, assign directlyto the compile options module.Example The following example shows how to set up the GNU compileron a machine running Solaris.> p := define_external(‘COMPILE_OPTIONS‘):> p:-COMPILER := "gcc";> p:-COBJ_FLAG := "-o ":> define_external(‘mat_mult‘,‘WRAPPER‘,‘LIB‘="libcexttest.so"):The gcc requires a space between -o and the object name. Modifyingthe COBJ_FLAG allows this to be easily done. All other option defaultvalues are acceptable.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!