Alex Vong <alexvong1...@gmail.com> writes: > Hi people, > > > I got the following error message when trying to dlopen a shared library > in ~/guix-profile/bin/guile installed by guix: > > scheme@(guile-user)> (dynamic-link "libm") > ERROR: In procedure dynamic-link: > ERROR: In procedure dynamic-link: file: "libm", message: "file not found" > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > > > I think it is a guix-specific problem since /usr/bin/guile installed by > debian works fine: > > scheme@(guile-user)> (dynamic-link "libm") > $1 = #<dynamic-object "libm"> The `dynamic-link` will search and dlopen the shared library. The guile from guix doesn’t search common places like ‘/usr/lib’, so you need to set the environment variable `LD_LIBRARY_PATH` or `LTDL_LIBRARY_PATH` explicitly to the directory contains `libm.so`.
by the way, since guile is linked with libm.so, we can just use `(dynamic-link)` here. well, I also find `(dynamic-link "libm-2.22")` work too, but it doesn’t seem to be what we want to use.