The library file Library.pl must contain a tool/2 call for each of the specified predicates.
Predicates declared as autoloaded are always defined as global but note that the module directive in a file erase the module completely so that the autoloaded procedure (and its visibility) are removed completely before being recompiled. This means that the global declaration must be present in the file.
Success:
[eclipse]: get_flag(library_path, Path),
get_flag(cwd, Cwd),
set_flag(library_path, [Cwd | Path]).
Cwd = "/home/user/"
Path = ["/usr/local/ECLIPSE/lib"]
yes.
[eclipse]: open("my_lib.pl", write, s),
write(s, ":- module(my_lib).\n"),
write(s, ":- global p/0.\n"),
write(s, ":- tool(p/0, writeln/1)."),
close(s).
yes.
[eclipse]: autoload_tool(my_lib, [p/0]).
yes.
[eclipse]: p. % when p/0 is called, the library is
% compiled first, ie. autoloaded.
loading the library /home/user/my_lib.pl
eclipse
yes.
[eclipse]: p. % p/0 is not an autoloaded pred anymore
eclipse
yes.
Error:
autoload_tool(Lib, [p/0]). (Error 4).
autoload_tool(a_lib, L). (Error 4).
autoload_tool("a_lib", [p/0]). (Error 5).
autoload_tool(a_lib, [1]). (Error 5).
autoload_tool(a_lib, p/0). (Error 5).
[eclipse]: [user].
p :- t. % call compiled before tool declaration
user compiled 32 bytes in 0.00 seconds
yes.
[eclipse]: autoload_tool(a_lib, [t/0]). (Error 62).
autoload_tool(not_a_file, [p/0]). (Error 173).