• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

12.2 Linking Foreign Modules
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • Linking Foreign Modules
          • What linking is provided?
          • What kind of loading should I be using?
          • library(shlib): Utility library for loading foreign objects (DLLs, shared objects)
          • Low-level operations on shared libraries
            • open_shared_object/2
            • open_shared_object/3
            • close_shared_object/1
            • call_shared_object_function/2
          • Static Linking
    • Packages

12.2.4 Low-level operations on shared libraries

The interface defined in this section allows the user to load shared libraries (.so files on most Unix systems, .dll files on Windows). This interface is portable to Windows as well as to Unix machines providing dlopen(2) (Solaris, Linux, FreeBSD, Irix and many more) or shl_open(2) (HP/UX). It is advised to use the predicates from section 12.2.3 in your application.

open_shared_object(+File, -Handle)
File is the name of a shared object file (DLL in MS-Windows). This file is attached to the current process, and Handle is unified with a handle to the library. Equivalent to open_shared_object(File, Handle, []). See also open_shared_object/3, load_foreign_library/1 and use_foreign_library/1.

On errors, an exception shared_object(Action, Message) is raised. Message is the return value from dlerror().

open_shared_object(+File, -Handle, +Options)
As open_shared_object/2, but allows for additional flags to be passed. Defined options are below. These options map to RTLD_NOW, RTLD_LAZY, RTLD_GLOBAL, RTLD_NODELETE, RTLD_NOLOAD and RTLD_DEEPBIND on systems where this predicate is implemented using dlopen() and these flags are supported. If the flag is not supported on the target OS, the corresponding option is silently ignored.
resolve(Atom)
When to resolve symbols. Values are lazy (default) or now.
visibility(Atom)
Visibility of the new symbols. Values are are local (default) or global, making the new symbols available to all subsequently loaded shared objects.
now(Bool)
now(true) is the same as resolve(now). Provided for backward compatibility.
global(Bool)
global(true) is the same as visibility(global). Provided for backward compatibility.
delete(Bool)
If false, include RTLD_NODELETE.
load(Bool)
if false, include RTLD_NOLOAD. This returns a handle to the object if it is already loaded and NULL otherwise. It causes this predicate to fail silently if the object is not loaded.
deepbind(Bool)
if true, include RTLD_DEEPBIND.

Note that these flags may not be supported by your operating system. Check the documentation of dlopen() or equivalent on your operating system. Unsupported flags are silently ignored.

close_shared_object(+Handle)
Detach the shared object identified by Handle.
call_shared_object_function(+Handle, +Function)
Call the named function in the loaded shared library. The function is called without arguments and the return value is ignored. Normally this function installs foreign language predicates using calls to PL_register_foreign().

ClioPatria (version V3.1.1-51-ga0b30a5)