* how to use gsl with the guile ffi
@ 2018-12-28 13:15 tantalum
2018-12-28 13:30 ` Neil Jerram
0 siblings, 1 reply; 6+ messages in thread
From: tantalum @ 2018-12-28 13:15 UTC (permalink / raw)
To: Guile user
im getting the error "In procedure dynamic-link: file: "libgsl",
message: "file not found"" with the following code:
(import (system foreign))
(define gsl (dynamic-link "libgsl"))
* gsl (optionally?) depends on libgslcblas, which itself links without
error, but loading it with (dynamic-link) beforehand did not help
* some libraries work, for example libmagic. libm for example gives the
same error message
* the file /usr/lib/libgsl.so exists and is a symlink to the regular
file libgsl.so.23.1.0 whose content begins with ELF>
* similar problem on the mailing list
https://lists.gnu.org/archive/html/guile-user/2016-05/msg00010.html
* ive tried to set LD_LIBRARY_PATH with export to /usr/lib with no
apparent effect
* i was going from this manual entry
https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html
* guile (GNU Guile) 2.2.4
the issue can actually be reproduced with a c program:
#include <dlfcn.h>
#include <stdio.h>
int main () {
void* a = dlopen("libgsl.so", RTLD_NOW);
printf("got %p\n", a);
if (a) printf("ok\n"); else printf("error: %s\n", dlerror());
}
gcc t.c -ldl && ./a.out
the program only works without error when compiled with -lgslcblas.
so, it could be a more basic issue, but i dont know how to proceed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to use gsl with the guile ffi
2018-12-28 13:15 how to use gsl with the guile ffi tantalum
@ 2018-12-28 13:30 ` Neil Jerram
2018-12-28 15:51 ` tantalum
2018-12-28 20:01 ` Matt Wette
0 siblings, 2 replies; 6+ messages in thread
From: Neil Jerram @ 2018-12-28 13:30 UTC (permalink / raw)
To: sph, Guile user
tantalum <sph@posteo.eu> writes:
> im getting the error "In procedure dynamic-link: file: "libgsl",
> message: "file not found"" with the following code:
>
> (import (system foreign))
> (define gsl (dynamic-link "libgsl"))
>
> * gsl (optionally?) depends on libgslcblas, which itself links without
> error, but loading it with (dynamic-link) beforehand did not help
> * some libraries work, for example libmagic. libm for example gives the
> same error message
> * the file /usr/lib/libgsl.so exists and is a symlink to the regular
> file libgsl.so.23.1.0 whose content begins with ELF>
> * similar problem on the mailing list
> https://lists.gnu.org/archive/html/guile-user/2016-05/msg00010.html
> * ive tried to set LD_LIBRARY_PATH with export to /usr/lib with no
> apparent effect
> * i was going from this manual entry
> https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html
> * guile (GNU Guile) 2.2.4
>
> the issue can actually be reproduced with a c program:
>
> #include <dlfcn.h>
> #include <stdio.h>
>
> int main () {
> void* a = dlopen("libgsl.so", RTLD_NOW);
> printf("got %p\n", a);
> if (a) printf("ok\n"); else printf("error: %s\n", dlerror());
> }
>
> gcc t.c -ldl && ./a.out
>
> the program only works without error when compiled with -lgslcblas.
> so, it could be a more basic issue, but i dont know how to proceed.
You could run under strace to confirm which files are being looked for,
and which of those are not found.
Regards,
Neil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to use gsl with the guile ffi
2018-12-28 13:30 ` Neil Jerram
@ 2018-12-28 15:51 ` tantalum
2018-12-28 16:45 ` Neil Jerram
2018-12-28 20:01 ` Matt Wette
1 sibling, 1 reply; 6+ messages in thread
From: tantalum @ 2018-12-28 15:51 UTC (permalink / raw)
To: Neil Jerram; +Cc: Guile user
so far i couldnt find the cause with strace.
mmap(NULL, 80013, PROT_READ, MAP_PRIVATE,
7</usr/lib/guile/2.2/ccache/system/foreign.go>, 0) = 0x7f6a6da6b000
close(7</usr/lib/guile/2.2/ccache/system/foreign.go>)
= 0
mprotect(0x7f6a6da7b000, 8776, PROT_READ|PROT_WRITE)
= 0
openat(AT_FDCWD, "/usr/lib/libgslcblas.la", O_RDONLY)
= -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib32/libgslcblas.la", O_RDONLY)
= -1 ENOENT (No such file or directory)
access("/usr/lib/libgslcblas.so", R_OK)
= 0
futex(0x7f6a73843048, FUTEX_WAKE_PRIVATE, 2147483647)
= 0
openat(AT_FDCWD, "/usr/lib/libgslcblas.so", O_RDONLY|O_CLOEXEC)
= 7</usr/lib/libgslcblas.so.0.0.0>
read(7</usr/lib/libgslcblas.so.0.0.0>,
"\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\"\0\0\0\0\0\0@\0\0\0\0\0\0\0\360\340\3\0\0\0\0\0\0\0\0\0@\08\0\7\0@\0\26\0\25\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0"...,
832) = 832
fstat(7</usr/lib/libgslcblas.so.0.0.0>, {st_mode=S_IFREG|0755,
st_size=255600, ...}) = 0
mmap(NULL, 2351120, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
7</usr/lib/libgslcblas.so.0.0.0>, 0) = 0x7f6a6d82c000
mprotect(0x7f6a6d86a000, 2093056, PROT_NONE)
= 0
mmap(0x7f6a6da69000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7</usr/lib/libgslcblas.so.0.0.0>,
0x3d000) = 0x7f6a6da69000
close(7</usr/lib/libgslcblas.so.0.0.0>)
= 0
mprotect(0x7f6a6da69000, 4096, PROT_READ)
= 0
openat(AT_FDCWD, "/usr/lib/libgsl.la", O_RDONLY)
= -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib32/libgsl.la", O_RDONLY)
= -1 ENOENT (No such file or directory)
access("/usr/lib/libgsl.so", R_OK)
= 0
openat(AT_FDCWD, "/usr/lib/libgsl.so", O_RDONLY|O_CLOEXEC)
= 7</usr/lib/libgsl.so.23.1.0>
read(7</usr/lib/libgsl.so.23.1.0>,
"\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`l\5\0\0\0\0\0@\0\0\0\0\0\0\0\340+(\0\0\0\0\0\0\0\0\0@\08\0\7\0@\0\27\0\26\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0"...,
832) = 832
fstat(7</usr/lib/libgsl.so.23.1.0>, {st_mode=S_IFREG|0755,
st_size=2634144, ...}) = 0
mmap(NULL, 4730464, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
7</usr/lib/libgsl.so.23.1.0>, 0) = 0x7f6a6d3a9000
mprotect(0x7f6a6d617000, 2097152, PROT_NONE)
= 0
mmap(0x7f6a6d817000, 86016, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7</usr/lib/libgsl.so.23.1.0>,
0x26e000) = 0x7f6a6d817000
close(7</usr/lib/libgsl.so.23.1.0>)
= 0
munmap(0x7f6a6d3a9000, 4730464)
= 0
openat(AT_FDCWD, "/usr/share/locale/en_GB.UTF-8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_GB.utf8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_GB/LC_MESSAGES/libc.mo",
O_RDONLY) = 7</usr/share/locale/en_GB/LC_MESSAGES/libc.mo>
fstat(7</usr/share/locale/en_GB/LC_MESSAGES/libc.mo>,
{st_mode=S_IFREG|0644, st_size=1474, ...}) = 0
mmap(NULL, 1474, PROT_READ, MAP_PRIVATE,
7</usr/share/locale/en_GB/LC_MESSAGES/libc.mo>, 0) = 0x7f6a743b8000
close(7</usr/share/locale/en_GB/LC_MESSAGES/libc.mo>)
= 0
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY)
= -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/libgsl.la", O_RDONLY)
= -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/libgsl.so", O_RDONLY|O_CLOEXEC)
= 7</usr/lib/libgsl.so.23.1.0>
read(7</usr/lib/libgsl.so.23.1.0>,
"\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`l\5\0\0\0\0\0@\0\0\0\0\0\0\0\340+(\0\0\0\0\0\0\0\0\0@\08\0\7\0@\0\27\0\26\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0"...,
832) = 832
fstat(7</usr/lib/libgsl.so.23.1.0>, {st_mode=S_IFREG|0755,
st_size=2634144, ...}) = 0
mmap(NULL, 4730464, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
7</usr/lib/libgsl.so.23.1.0>, 0) = 0x7f6a6d3a9000
mprotect(0x7f6a6d617000, 2097152, PROT_NONE)
= 0
mmap(0x7f6a6d817000, 86016, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7</usr/lib/libgsl.so.23.1.0>,
0x26e000) = 0x7f6a6d817000
close(7</usr/lib/libgsl.so.23.1.0>)
= 0
munmap(0x7f6a6d3a9000, 4730464)
= 0
openat(AT_FDCWD, "/usr/lib/guile/2.2/extensions/libgsl.la", O_RDONLY)
= -1 ENOENT (No such file or directory)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to use gsl with the guile ffi
2018-12-28 15:51 ` tantalum
@ 2018-12-28 16:45 ` Neil Jerram
0 siblings, 0 replies; 6+ messages in thread
From: Neil Jerram @ 2018-12-28 16:45 UTC (permalink / raw)
To: sph; +Cc: Guile user
tantalum <sph@posteo.eu> writes:
> so far i couldnt find the cause with strace.
Well I think I'm just stating the obvious here, but clearly
libgslcblas.so is OK -
> openat(AT_FDCWD, "/usr/lib/libgslcblas.so", O_RDONLY|O_CLOEXEC)
> = 7</usr/lib/libgslcblas.so.0.0.0>
- and also libgsl.so -
> openat(AT_FDCWD, "/usr/lib/libgsl.so", O_RDONLY|O_CLOEXEC)
> = 7</usr/lib/libgsl.so.23.1.0>
- but apparently the system also needs libgsl.la, and that isn't found
at the expected place:
> openat(AT_FDCWD, "/usr/lib/guile/2.2/extensions/libgsl.la", O_RDONLY)
> = -1 ENOENT (No such file or directory)
I'm afraid I don't know any more, e.g. about whether libgsl.la _should_
be needed here.
Neil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to use gsl with the guile ffi
2018-12-28 13:30 ` Neil Jerram
2018-12-28 15:51 ` tantalum
@ 2018-12-28 20:01 ` Matt Wette
1 sibling, 0 replies; 6+ messages in thread
From: Matt Wette @ 2018-12-28 20:01 UTC (permalink / raw)
To: guile-user
tantalum <sph@posteo.eu> writes:
>> im getting the error "In procedure dynamic-link: file: "libgsl",
>> message: "file not found"" with the following code:
>>
>> (import (system foreign))
>> (define gsl (dynamic-link "libgsl"))
>>
>> * gsl (optionally?) depends on libgslcblas, which itself links without
>> error, but loading it with (dynamic-link) beforehand did not help
>> * some libraries work, for example libmagic. libm for example gives the
>> same error message
>> * the file /usr/lib/libgsl.so exists and is a symlink to the regular
>> file libgsl.so.23.1.0 whose content begins with ELF>
>> * similar problem on the mailing list
>> https://lists.gnu.org/archive/html/guile-user/2016-05/msg00010.html
>> * ive tried to set LD_LIBRARY_PATH with export to /usr/lib with no
>> apparent effect
>> * i was going from this manual entry
>> https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html
>> * guile (GNU Guile) 2.2.4
>>
>> the issue can actually be reproduced with a c program:
>>
>> #include <dlfcn.h>
>> #include <stdio.h>
>>
>> int main () {
>> void* a = dlopen("libgsl.so", RTLD_NOW);
>> printf("got %p\n", a);
>> if (a) printf("ok\n"); else printf("error: %s\n", dlerror());
>> }
>>
>> gcc t.c -ldl && ./a.out
>>
>> the program only works without error when compiled with -lgslcblas.
>> so, it could be a more basic issue, but i dont know how to proceed.
>
I see this often enough. It is not a Guile issue. Your runtime needs to know
where to find the .so file. Typically you can fix this problem by setting
LD_LIBRARY_PATH prior to "guile". For HDF5 I need to ...
$ LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/hdf5/serial
$ export LD_LIBRARY_PATH
$ guile hdf5demo.scm
...
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to use gsl with the guile ffi
@ 2018-12-29 10:39 tantalum
0 siblings, 0 replies; 6+ messages in thread
From: tantalum @ 2018-12-29 10:39 UTC (permalink / raw)
To: matt.wette, guile-user
only thing is, im not sure yet what i would set LD_LIBRARY_PATH to, as the following are all the library files gsl installs:
gsl /usr/lib/libgsl.so
gsl /usr/lib/libgsl.so.23
gsl /usr/lib/libgsl.so.23.1.0
gsl /usr/lib/libgslcblas.so
gsl /usr/lib/libgslcblas.so.0
gsl /usr/lib/libgslcblas.so.0.0.0
ldd output is
ldd /usr/lib/libgsl.so
linux-vdso.so.1 (0x00007ffeb5ded000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f804bc32000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f804ba6e000)
/usr/lib64/ld-linux-x86-64.so.2 (0x00007f804c282000)
something that works in my c test program is preloading libgslcblas with RTLD_GLOBAL.
void* a = dlopen("/usr/lib/libgslcblas.so", RTLD_NOW | RTLD_GLOBAL);
void* b = dlopen("/usr/lib/libgsl.so", RTLD_NOW);
but guile uses libtool of course. as far as i understand it, libgslcblas is a cblas implementation that can be replaced with other ones, and that is why it is separate.
the RTLD_GLOBAL feature has been referenced in a mailing list post from 2012 "Re: using GSL with cblas via FFI"
https://lists.gnu.org/archive/html/guile-user/2012-06/msg00008.html
https://lists.gnu.org/archive/html/guile-user/2011-03/msg00071.html
what might eventually work is to compile gsl myself with the dependency excluded or statically linked. or using a c extension instead of the ffi.
but it is interesting also how the example from the manual does not work and gives the same error message. (define libm (dynamic-link "libm")) https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html
it would be interesting to know if it works for others.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-12-29 10:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-28 13:15 how to use gsl with the guile ffi tantalum
2018-12-28 13:30 ` Neil Jerram
2018-12-28 15:51 ` tantalum
2018-12-28 16:45 ` Neil Jerram
2018-12-28 20:01 ` Matt Wette
-- strict thread matches above, loose matches on Subject: below --
2018-12-29 10:39 tantalum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).