How to force FFI to load a library

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to force FFI to load a library

Annick
Hi,

I have one library which depends from another one.
How can I force pharo to load the dependent library ?

Annick

Reply | Threaded
Open this post in threaded view
|

Re: How to force FFI to load a library

Nicolai Hess
2014-10-22 14:50 GMT+02:00 Annick Fron <[hidden email]>:
Hi,

I have one library which depends from another one.
How can I force pharo to load the dependent library ?

Annick



I don't think it is necessary to force pharo to load the libraries. AFAIR the VM on linux uses dlopen() to load a module
and that should load the dependent libraries as well, *if* the library, you are using, is linked against the others.

For example, you want to load library "testlib" which depends on "helperlib"
you have to compile and link the testlib and helperlib as follows

gcc -shared -o libhelperlib.so helperlib.c
gcc -shared -o libtestlib.so testlib.c -L. -lhelperlib

now you should be able to load testlib from pharo.

you can test if your dependent libraries can be automatically found by dlopen with:
ldd <testlib>


nicolai