IMPORT (C-Extension)

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

Syntax

IMPORT cextname 
  1. cextname is an identifier defining the C extension module to be imported (without the file extension).

Usage

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

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 set up the system environment properly (such as PATH on Windows® and LD_LIBRARY_PATH on UNIX™) if the C extension library is dependent on 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.