IMPORT C-Extension

The IMPORT instruction imports c extension module elements to be used by the current module.

Syntax

IMPORT filename 
  1. filename is the identifier (without the file extension) of the C extension module to be imported.

Usage

Using IMPORT libname instructs the compiler and runtime system to use the libname C extension for the current module.

Important: At runtime, all imported C extension modules are loaded when the program starts.

The name of the module specified after the IMPORT keyword is converted to lowercase by the compiler. Therefore it is recommended to use lowercase file names only.

The C extension must exist as a shared library (.DLL or .so) and be loadable (environment variables must be set properly). C extension modules used with the IMPORT instruction do not have to be linked to fglrun: The runtime system loads dependent C extension modules dynamically.

The FGLLDPATH environment variable specifies the directories to search for the C extension modules. You may also have to setup the system environment properly (i.e. PATH on Windows™ and LD_LIBRARY_PATH on UNIX™) if the C extension library depends from other libraries.

By default, the runtime system tries to load a C extension module with the name userextension, if it exists. This simplifies the migration of existing C extensions; you just need to create a shared library named userextension.so (or userextension.dll on Windows), and copy the file to one of the directories defined in FGLLDPATH.