Error loading libreadline dll when using readline package

24 views
Skip to first unread message

K H

unread,
Apr 9, 2020, 2:49:33 AM4/9/20
to Racket Users
I'm running on cygwin on Windows 7 and I have the following error when attempting to use the readline package:

$ racket -il readline
Welcome to Racket v7.6.
ffi-lib: couldn't open "libreadline-5.dll" (The specified module could not be found.; errid=126)
> ,ex

I get the same error either from a cygwin bash prompt or from a windows cmd shell prompt.

The gnu readline installed appears to be at version 7.

$ ls -l /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libread*
-rwxr-xr-x  /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libreadline7.dll

The source at ./share/pkgs/readline-lib/readline/rktrl.rkt seems relevant but I'm not smart enough to figure out exactly what is wrong.

Any ideas on how to continue to debug this?

Thanks in advance,

Kieron.

Matthew Flatt

unread,
Apr 9, 2020, 9:02:29 AM4/9/20
to K H, Racket Users
I think you probably have the "readline-gpl" package installed. That's
where the "libreadline-5.dll" comes from in "private/readline-lib.rkt":

(define readline-library (ffi-lib "libreadline" '("5" "6" "4" "")))

Even if "7" were added to that list, `ffi-lib` assumes a versioning
convention that adds "-".

One solution is to set the

PLT_READLINE_LIB

environment variable to point to the full path of "libreadline7.dll".
Note that it will need to be a Windows path, though, not a Cygwin path.

Or you could also try copying "libreadline7.dll" to "libreadline.dll"
(no "7") in the Racket's "lib" directory, but that probably won't work
if "libreadline7.dll" depends on other libraries. And there's a
question of whether a Cygwin libreadline will work at all when loaded
into non-Cygwin Racket. It may work better to get another version of
the libreadline DLL from somewhere and drop it into Racket's "lib"
directory.
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAEEP09AXB4aJecs7eskog-RSDoyEeSW
> z5P_%2B8f4z%2B8%3DS7jEz%3Dw%40mail.gmail.com.

K H

unread,
Apr 9, 2020, 1:51:21 PM4/9/20
to Matthew Flatt, Racket Users
Thanks for the info, Matthew,

On Thu, Apr 9, 2020 at 7:02 AM Matthew Flatt <mfl...@cs.utah.edu> wrote:
I think you probably have the "readline-gpl" package installed. That's
where the "libreadline-5.dll" comes from in "private/readline-lib.rkt":
 
Yes. Prior to installing readline-gpl the file not found was "libreadline-3.dll". The error message change from "-3.dll" to "-5.dll" surprised me, and gave me hope that I was going in the right direction ...
 
 (define readline-library (ffi-lib "libreadline" '("5" "6" "4" "")))

I eventually found that line in ./7.6/share/readline-lib.rkt in the directory given by (find-config-dir) and was wondering about the ordering. Is 5,6,4 deliberate, or a typo and really should be 6,5,4?

Even if "7" were added to that list, `ffi-lib` assumes a versioning
convention that adds "-".

I added the "7" and of course discovered discovered the need for "-".

Would "bad things happen" if 'ffi-lib' (actually 'get-ffi-lib' in ffi/unsafe.rkt) were changed to look for both "-" and no separator? i.e. look for "<file>-<ver>.dll" then "<file><ver>.dll"? Is there a standard for the hyphen before the version that the cygwin package is breaking?

One solution is to set the

  PLT_READLINE_LIB

environment variable to point to the full path of "libreadline7.dll".
Note that it will need to be a Windows path, though, not a Cygwin path.

Shortly after first posting I discovered PLT_READLINE_LIB.

In a cygwin session, adding the location of "libreadline7.dll" to the path, and then setting PLT_READLINE_LIB was necessary only once. Subsequent sessions apparently do not necessarily need the environment variable to be set in order to find and load the ".dll". Is there some cache that is being used once the ".dll" has been found and loaded the first time?


Or you could also try copying "libreadline7.dll" to "libreadline.dll"
(no "7") in the Racket's "lib" directory, but that probably won't work
if "libreadline7.dll" depends on other libraries. And there's a
question of whether a Cygwin libreadline will work at all when loaded
into non-Cygwin Racket. It may work better to get another version of
the libreadline DLL from somewhere and drop it into Racket's "lib"
directory.

I'm not sure what to expect in a windows (i.e. non-cygwin) session. Indeed I seem to be experiencing weird and inconsistent behaviour, and perhaps need to experiment with minGW.

Cheers,

Kieron.


Reply all
Reply to author
Forward
0 new messages