Modules, include paths, swipl-ld etc
Kaitain Jones <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAMeycMz3R44KAC=PMTjOC1hn-68_6KHe8suSvQKvtwaaTr5atg@mail.gmail.com> |
I'm trying to get my head around how SWI gets hold of its modules, both in
general operation and when compiling a C executable that uses SWI.
Take a case such as the predicate intersection/1. SWI manual says of this:
Availability::-
use_module(library(lists)<http://www.swi-prolog.org/pldoc/man?section=lists>
).(can be autoloaded)
Okay. Now in the REPL it's available immediately. Indeed it seems that
everything (?) is always available in the REPL. Is this because we don't
care about memory footprint in the REPL but want to control it in an
independent program?
Next: I am trying to have my exe consult files dynamically at runtime,
including those which make use of (say) intersection/1. However, I can't do
this right now. (At least, not when using swipl-ld on Linux; I'll come to
Win32/Visual Studio later.) If I put
:- use_module(library(lists)).
...in the .pl file, the exe is having none of it at runtime:
ERROR: /MyDir/common_scenario_rules.pl:1:
source_sink `library(lists)' does not exist
Warning: /MyDir/common_scenario_rules.pl:1:
Goal (directive) failed: user:use_module(library(lists))
If I remove that line, though, it (predictably) just fails in another way:
ERROR: can_traverse_link_between/4: Undefined procedure: intersection/3
Now, I am assuming in the first case that your exe needs to have all the
modules it will ever need at the time it is compiled, and can't pull them
in dynamically at runtime, i.e. if you want the lists library, it has to be
pulled in as part of the swipl-ld compilation process. (Is this correct?) I
don't really want to do that, though, because I can't use swipl-ld for
building my Win32 exe in Visual Studio. Ideally I'd like my Linux and Win32
builds to operate functionally in the same way, i.e. to pull everything in
dynamically at runtime, which is what I'm doing on Win32. Which brings me
on to...
On Win32, everything works fine. So far as I can tell, compiling with the
libswipl.lib and running with the appropriate dlls works out just fine. I
don't even need to add the use_module directives; all my predicates work
just fine anyway.
So what's the big difference between how Win32 is working and how my
Linux/swipl-ld build is working? Is there a way I can get my files to load
at runtime without baking the modules in at compile time on Linux?
One other complication: I think I am now running with SWI V7 on Windows,
whereas I am still on 6.6 on Linux. (Is there any way to get 7 on Linux
without building from sources?)
Thanks for any illumination anyone can offer,
KJ
-------------- next part --------------
HTML attachment scrubbed and removed