lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Jul 28, 2017 at 11:22 AM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> Would you be open to considering dlopen()'ing readline? Then you
>> wouldn't have to worry about it actually being installed, you'd just
>> detect it at runtime and use it if it's available.
>
> Oh, this may open another big can of worms. For instance, which is the
> full path of the readline.so to use in dlopen?
>
> However, this does not solve the problem because lua.c has to call
> readline and cannot detect this at compiel time.
>
> If you could provide working code for your suggestion, I'd like to see it.
>

I don't believe you actually need to know the full path. On the two
platforms I have available to me for testing -- Linux and OSX -- if
you give dlopen() a path that does not contain a slash then it will
search the system library path for the library in question. A Google
search for the FreeBSD and Solaris man pages for dlopen() says that it
works there, too.

You would have to subsequently use dlsym() to get the functions you
need to call instead of using header files, so it's definitely a bit
of extra code, although you could fall back to basic stdio functions
afterward.

I don't have time to write code at the present moment, but I'll see if
I can get back to you on that.

/s/ Adam