Runtime exception on Linux: cannot open shared object file: No such file or directory

Kaitain Jones <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAMeycMxPbOSxPQsM95Xe5xxPb_bcy-2vXQoLLvL6iEEg1j5xPQ@mail.gmail.com>
Using swipl-ld on Ubuntu 12.04 64-bit.

Just compiling, linking and running Jan's very basic example foreign
language interface code as detailed here:

http://www.swi-prolog.org/pldoc/man?section=plld

I find I have to compile with some extra flags to pull in the libs that
seem to be necessary for full compilation/linking. Instead of:

swipl-ld -o calc calc.c calc.pl


I have to use:

swipl-ld -o calc calc.c calc.pl -lgmp -lrt -lm -lncurses -ldl -lunwind


This all seems to compile okay:

% calc.pl compiled 0.00 sec, 2 clauses
% autoloading prolog_codewalk:must_be/2 from /usr/lib/swi-prolog/library/error
% autoloading prolog_codewalk:portray_clause/1 from
/usr/lib/swi-prolog/library/listing
% autoloading prolog_codewalk:clause_info/4 from
/usr/lib/swi-prolog/library/prolog_clause
% autoloading prolog_codewalk:initialization_layout/4 from
/usr/lib/swi-prolog/library/prolog_clause
% autoloading error:assertion/1 from /usr/lib/swi-prolog/library/debug
% autoloading record:member/2 from /usr/lib/swi-prolog/library/lists
% autoloading prolog_source:directory_file_path/3 from
/usr/lib/swi-prolog/library/filesex
% autoloading files_ex:use_foreign_library/2 from
/usr/lib/swi-prolog/library/shlib
% autoloading qsave:current_foreign_library/2 from
/usr/lib/swi-prolog/library/shlib
% autoloading prolog_debug:backtrace/1 from
/usr/lib/swi-prolog/library/prolog_stack
% autoloading oset:reverse/2 from /usr/lib/swi-prolog/library/lists
% autoloading prolog_codewalk:clause_name/2 from
/usr/lib/swi-prolog/library/prolog_clause
% Autoloader: iteration 1 resolved 11 predicates and loaded 12 files
in 0.048 seconds.  Restarting ...
% autoloading files_ex:permission_error/3 from /usr/lib/swi-prolog/library/error
% autoloading files_ex:maplist/2 from /usr/lib/swi-prolog/library/apply
% Autoloader: loaded 11 files in 2 iterations in 0.075 seconds
% halt

It actually runs, and the output is as desired. But at the start there's
always a (seemingly benign) exception/error that gets triggered on
initialization:


> *./calc pi/2**ERROR: /usr/lib/swi-prolog/library/filesex.pl:57: Initialization goal raised exception:
ERROR: '$open_shared_object'/3: files: cannot open shared object file:
No such file or directory*
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.4.1)
Copyright (c) 1990-2013 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

1.5707963267948966


I first encountered this while trying to build a much larger project, and
wondered if I had introduced the issue myself. But I stripped things down
to Jan's simple example and it's visible there, too. I googled for similar
problems and saw that other people were having them (albeit with different
libs) but I couldn't really tell from his responses if Jan was saying that
this would be a general issue on Linux, or whether it would be expected
only if you were trying to use specific files:

"You should create a small hierarchy that includes the required
.so files and makes sure that the file-search-path 'foreign'
can find these files.  There are many ways to do that."


The exception doesn't actually cause any issues with program execution so
far as I can tell (in either the example program or my program), but I
never like things I don't fully understand and am wondering if this will
bite me later. If anyone can shed some light on what's going on I'd be
grateful.

KJ
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.