• 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

14.2 Understanding saved states
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Deploying applications
        • Understanding saved states
          • Creating a saved state
          • Limitations of qsave_program
          • Runtimes and Foreign Code
    • Packages

14.2.3 Runtimes and Foreign Code

Many applications use packages that include foreign language components compiled to shared objects or DLLs. This code is normally loaded using use_foreign_library/1 and the foreign file search path. Below is an example from the socket library.

:- use_foreign_library(foreign(socket)).

There are two options to handle shared objects in runtime applications. The first is to use the foreign(save) option of qsave_program/2 or the --foreign=save commandline option. This causes the dependent shared objects to be included into the resource archive. The use_foreign_library/1 directive first attempts to find the foreign file in the resource archive. Alternatively, the shared objects may be placed in a directory that is distributed with the application. In this cases the file search path foreign must be setup to point at this directory. For example, we can place the shared objects in the same directory as the executable using the definition below. This may be refined further by adding subdirectories depending on the architecture as available from the Prolog flag arch.

:- multifile user:file_search_path/2.

user:file_search_path(foreign, Dir) :-
    current_prolog_flag(executable, Exe),
    file_directory_name(Exe, Dir).

ClioPatria (version V3.1.1-51-ga0b30a5)