rnowley / nim-ncurses

A Nim language wrapper for NCurses
57 stars 12 forks source link

Problem with using 'libncursesw.so' (Linux) #15

Open runkharr opened 5 years ago

runkharr commented 5 years ago

Hi!

You should not use 'libncursesw.so' directly as a 'dynlib' under Linux, because there is a high probability that this file is a linker script containing the line

INPUT(libncursesw.so.5 -ltinfo)

(or)

INPUT(libncursesw.so.6 -ltinfo)

Instead, you should use there 'libncursesw.so.(5|6)'. I checked this, and it works. The original 'libncursesw.so' leads to the following error message when invoking a program which was linked with your 'ncurses'-module:

could not load: libncursesw.so
compile with -d:nimDebugDlOpen for more information

With the mentioned flag set, the following error message is printed when this program is invoked:

/usr/lib/x86_64-linux-gnu/libncursesw.so: file too short
could not load: libncursesw.so

The reason for this behaviour is that 'dlopen()' is unable to handle linker scripts. Linker scripts are meant to be used solely with the linker 'ld'. I doubt that 'dlopen()' will ever be able to handle such files, because they may contain anything ld's scripting language supports, even dependencies on static libraries ('XXX.a').

Nim seems currently unable to generate modules containing dynamically loadable object files, but, until (if ever) this is the case, workarounds as described above must be used.

If you wish, i could create a pull-request with the fix, but currently this is bothersome for me, as i have little time for such things, and i have made no good experiences with these things (yet).

Greetings\     runkharr