unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Setting
@ 2024-11-02 15:25 Adam McCartney
  0 siblings, 0 replies; only message in thread
From: Adam McCartney @ 2024-11-02 15:25 UTC (permalink / raw)
  To: guile-user

Dear Guile Users!

I wonder if one of you might be able to help me understand how 
GUILE_EXTENSIONS_PATH is supposed to find shared libraries. My understanding 
from reading the docs is that using the GUILE_EXTENSIONS_PATH variable is the 
preferred way to do this as of guile 3.0.6

 From the docs:

> Unless library denotes an absolute file name or otherwise contains a directory 
> separator (/, and also \ on Windows), Guile will search for the library in the 
> directories listed in search-paths. The default search path has three 
> components, which can all be overridden by colon-delimited (semicolon on 
> Windows) environment variables:

I'm using `guile-3.0.9` from `guix` and my program doesn't seem to be able to
locate the shared library. Initially I thought it might have to do with guile
not picking up the GUILE_EXTENSION_PATH variable correctly from the environment.

At the moment, I'm just trying to run a very simple program:

   (use-modules (system foreign-library))
   (load-foreign-library "libpd")

To be clear, it seems to work fine if I set the variable and start an
interactive bash session and from there launch guile. However, I'd like to be 
able to run the program directly like the following:

   guix shell -m manifest -- guile -s src/main.scm

This seems to _not_ pick up the GUILE_EXTENSION_PATH variable as expected.
Probably I'm missing something obvious about how guile starts up from within
a guix shell. I tried the invocation:
   
   guix shell -m manifest -- \
   env GUILE_EXTENSION_PATH=$GUIX_ENVIRONMENT/lib \
   guile
   -s src/main.scm

And was surprised to see that it doesn't pick up GUIX_ENVIRONMENT - I guess this
makes sense as the environment probably hasn't been loaded yet?

So back in guile land, I tried to set the GUILE_EXTENSION_PATH variable from an 
interactive guile session:
   scheme@(guile-user)> (setenv "GUILE_EXTENSIONS_PATH" (string-append (getenv "GUIX_ENVIRONMENT") "/lib"))

And tried to load the libary:
   scheme@(guile-user)> (use-modules (system foreign-library))
   scheme@(guile-user)> (load-foreign-library "libpd")
   ice-9/boot-9.scm:1685:16: In procedure raise-exception:
   In procedure dlopen: file "libpd.so", message "libpd.so: cannot open shared object file: No such file or directory"


But it's definitely there:
   scheme@(guile-user)> (load-foreign-library (string-append (getenv "GUILE_EXTENSIONS_PATH") "/libpd"))
   $3 = #<<foreign-library> filename: "/gnu/store/25m9fzb29dqi5r3pvigpcdvv2hrz8w8b-profile/lib/libpd" handle: #<pointer 0x19d60c60>>


Anyway, I can probably find a workaround for this, but I'm just wondering if I 
miss something? Any help would be much appreciated!

Regards,
Adam

-- 
  Adam McCartney - https://admccartney.mur.at 
/



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-02 15:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-02 15:25 Setting Adam McCartney

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).