Sunday, 13 September 2015

Re: [gccsdk] dlopen query

On 13/09/15 10:46, Gavin Wraith wrote:
> I have compiled Lua with GCC 4.7.4. There are two sorts of libraries
> that Lua can load - those written in Lua, and those written in C
> to be dynamically linked with the interpreter. Both use
> environment variables to search for the libraries, namely
> LUA_PATH and LUA_CPATH respectively. These are lists of
> templates of filepaths. A template is just a wildcarded
> filepath; the wildcard is replaced by the library name.
> The user can set variables when the interpreter is compiled that
> determine the directory-separator symbol ('.' for RISC OS) and
> the template item-separator (',' for RISC OS) and the wildcard
> ('?' for RISC OS). This set up has been designed to be as portable
> as possible to any system.

> The libraries written in Lua load just fine, but those written in
> C do not - a 'file not found' error is returned. The former are
> loaded with the io C-library, which I presume has been tweaked
> to understand RISC OS filenaming practices. The latter are
> loaded by dlopen in the dlfcn C-library. It looks to me as if
> this has not been so tweaked. Lee's remark in his post on
> 09/09 about using a forward slash as a prefix to the pathname
> given to dlopen would seem to confirm this. I tried doing this
> but no joy. If users are to be able to put the application where
> they want, pathnames that have to be evaluated by RISC OS,
> like MyApp:lib.so.foo, are needed. I suspect that this may be why
> I am getting 'file not found' errors.

How are you storing your libraries? The dynamic linker does do Unix
to RISC OS conversion in terms of directory separators, but not for
suffix swapping. Suffix swapping doesn't really make sense for shared
libraries as the .so may not always be at the end of the name, if there
is a version number. In RISC OS, your libraries should be of the form:

MyApp:lib.foo/so

ie, a library file called "foo/so" in directory "lib" on path "MyApp".
You then pass it to dlopen as:

/MyApp:lib/foo.so

ie, in Unix style. The dynamic linker will then convert to the RISC OS
format when performing file operations.
I assume you're setting LUA_CPATH to "/MyApp:lib/" and then expecting
the dlfcn library to use that to build the correct filename. If your
libraries are named correctly as above, then that may work, but you
may have to tweak the dlfcn library to get the filenames correct.

Lee.


_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK

No comments:

Post a Comment