function library
A function library AKA library is a collection of functions designed to be called by other programs and/or function libraries.  A function library is like a conventional program, except:

  its PROGRAM statement argument must be the same as its filename.
  its external variables are not accessible to other programs or dlls.
  its entry function does little or nothing except initialization.
  its entry function is called automatically when imported.
  it doesn't usually perform a complete activity by itself.
  it is compiled as a function library.

The math library is a good example: "xma" has no external variables, its entry function does nothing, and it performs no coherent activity.  It exists only to make its individual math functions and constants available to other programs.  Accessory toolsets for GuiDesigner are also function libraries.

When a function library is created, the PDE saves a file called libname.dec, where libname is the name of the program.  libname.dec contains all lines in EXPORT ... END EXPORT blocks in library prologs.

libname.dec is needed by programs that IMPORT "libname".

system functions and foreign functions
System functions are library functions in the operating system, for example Win32 APIs for Windows95/98/NT, and system-call functions in Linux.  Foreign functions are library functions written in some other programming language that has a compatible function interface.

Both are treated as foreign functions in the following discussion.

Programs can call foreign functions just like its own functions and functions in native function libraries.  To make foreign functions visible, list the libraries that contains them in the PROLOG, in IMPORT statements - as in IMPORT "kernel32".

Foreign functions and function libraries must have libname.dec files.  You'll have to create them yourself or find a company that sells them as an accessory product.  It isn't difficult to create or supplement libname.dec files yourself, since you only have to include declarations for the types, functions, and constants that your program references.   Later you can add new type, function, and constant declarations on an as needed basis.  The definitions for type and functions are available in operating system documentation as well as libname.h files.

Some libname.dec files are provided with the PDE to make it easy to call common system functions, and kernel32.dec is one example.  These system declaration files don't usually contain every data type, constant, and function in the system function library, but you can add them on an as needed basis.

libname.def files are not required to access foreign functions referenced by programs being run in the program development environment, but they are usually required to make standalone executables. libname.def is not needed for system functions since libname.lib files already exist.