unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Adam McCartney <adam@mur.at>
To: guile-user@gnu.org
Subject: Setting
Date: Sat, 2 Nov 2024 16:25:51 +0100	[thread overview]
Message-ID: <ZyZEf3Ar6WkfqWr9@malloy> (raw)

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 
/



                 reply	other threads:[~2024-11-02 15:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZyZEf3Ar6WkfqWr9@malloy \
    --to=adam@mur.at \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).