HiTECNOLOGYs / cl-charms

More up-to-date version of cl-charms. Forked it because it was, apparently, abandoned by author and I couldn't contact him.
https://gitorious.org/cl-charms
Other
158 stars 29 forks source link

Load Foreign Library Error #23

Closed kvsari closed 8 years ago

kvsari commented 8 years ago

Using ECL on ArchLinux x86_64 (same occurs in clisp). (ql:quickload :cl-charms-timer) Errors with; Condition of type: LOAD-FOREIGN-LIBRARY-ERROR Unable to load any of the alternatives: ("libncurses.so.5" "libcurses")

I could only track the error to src/low-level/curses-bindings.lisp line 61. Trying to change it to ask for libncurses.so.6 which is present in /usr/lib still doesn't work.

kvsari commented 8 years ago

I've gotten it to work. I've changed line 61 from "libncurses.so.5" to "libncursesw.so.6.0". Confirmed to work on ECL on ArchLinux ARMv7 so far with cl-charms-timer and cl-charms-paint.

HiTECNOLOGYs commented 8 years ago

Right, libncurses.so.5 is probably a link made by your package manager. CFFI doesn't handle those well so you need to pass fully qualified name of your library. I still haven't figured out what to do with that nasty "feature" of CFFI but it seems like it's easier to just hardcode those paths for all the platforms that figure out how to parse the instructions for linker.

If you can confirm that libncurses.so.5 is just a text file with linker instructions, I'll close this. If not, we'll need to investigate more since it should have loaded it then.

stylewarning commented 8 years ago

Can we just add libncursesw.so as an alternative within the definition?

It fact, it might be preferable to look for that library first (maybe even only) since we make extensive use of the w functions.

HiTECNOLOGYs commented 8 years ago

No, we can't. Many (EDITED: well, not that many, but some still do and it'll break things) distributions keep linker instructions file instead of actual library there, so CFFI won't be able to load it. For example, I have the following in mine libncursesw.so:

/* GNU ld script
   Since Gentoo has critical dynamic libraries in /lib, and the static versions
   in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
   run into linking problems.  This "fake" dynamic lib is a linker script that
   redirects the linker to the real lib.  And yes, this works in the cross-
   compiling scenario as the sysroot-ed linker will prepend the real path.

   See bug http://bugs.gentoo.org/4411 for more info.
 */
OUTPUT_FORMAT ( elf64-x86-64 )
GROUP ( /lib64/libncursesw.so.5 )

What we need to do is add libncursesw.so.6 to definition since ncurses 6.0 was released recently (well, on 8th of August).

kvsari commented 8 years ago

On ArchLinux ARMv7 and x86_64; $ more /usr/lib/libncurses.so INPUT(-lncursesw)

There is no libncurses.so.5 file. If there is a version number they are all 6. Perhaps a simple addition, an extra :or libncurses.so.6 or something if .5 isn't found?

roygbyte commented 1 year ago

Hi! I too would like to play around with Common Lisp and ncurses, but I'm facing the same challenge (yes, even in 2023) of getting CFFI to find libncursesw.so. I've faffed around with links have not "found the light." I do not know my mistake, but CFFI does not seem to be finding my ncurses package. Far as I can tell my link is fine:

lrwxrwxrwx   1 root root      36 Feb 27 21:16 libncursesw.so -> /lib/x86_64-linux-gnu/libncursesw.so

I would soooo appreciate some help! I have big dreams of integrating ancient libraries into my life. If someone has a minute, please help!

stylewarning commented 1 year ago

Hi! I too would like to play around with Common Lisp and ncurses, but I'm facing the same challenge (yes, even in 2023) of getting CFFI to find libncursesw.so. I've faffed around with links have not "found the light." I do not know my mistake, but CFFI does not seem to be finding my ncurses package. Far as I can tell my link is fine:


lrwxrwxrwx   1 root root      36 Feb 27 21:16 libncursesw.so -> /lib/x86_64-linux-gnu/libncursesw.so

I would soooo appreciate some help! I have big dreams of integrating ancient libraries into my life. If someone has a minute, please help!

Is :UNICODE in your *features*?

roygbyte commented 1 year ago

Welp! I checked the features and both :SB-UNICODE and :ASDF-UNICODE were enabled. The problem in actuality was the SBCL version. I was running 1.4.3 installed on Ubuntu 22.04, installed from the distro's packages. Big no, I guess! Making and running SBCL from source at version 2.3.2 proved to be the solution. The timer app runs!