Something like TProcess.Environment for libraries ?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Something like TProcess.Environment for libraries ?

fredvs
Hello.

If you are using a TProcess and your executable depends on libraries, there is TProcess.Environment to define the library path, example:

AProcess.Environment.Text := 'LD_LIBRARY_PATH=' + alibrarypath;

For library, LoadLibrary(alibrary) loads dynamicaly it-self but if the library depends on other libraries how to define that libraries-path (if <> lib-system-path)  ?

Thanks.

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Something like TProcess.Environment for libraries ?

fredvs
Hello.

After googling, I found that it is possible to use a parameter for the linker:
http://stackoverflow.com/questions/2726993/how-to-specify-preference-of-library-path

For a c program:

"Use the rpath option via gcc to linker - runtime library search path, will be used instead of looking in standard dir (gcc option): -Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)"

Could it be possible to fpc to use that option while linking ?

Thanks.

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Something like TProcess.Environment for libraries ?

Jonas Maebe-3

fredvs wrote:

> After googling, I found that it is possible to use a parameter for the
> linker:
> http://stackoverflow.com/questions/2726993/how-to-specify-preference-of-library-path
>
> For a c program:
>
> "Use the rpath option via gcc to linker - runtime library search path, will
> be used instead of looking in standard dir (gcc option):
> -Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)"
>
> Could it be possible to fpc to use that option while linking ?

FPC's way to pass custom parameters to the linker is using the -k
parameter: -k-rpath -k$(DEFAULT_LIB_INSTALL_PATH), or "-k-rpath
$(DEFAULT_LIB_INSTALL_PATH)"


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Something like TProcess.Environment for libraries ?

fredvs
Hello Jonas.

>  -k-rpath -k$(DEFAULT_LIB_INSTALL_PATH), or "-k-rpath $(DEFAULT_LIB_INSTALL_PATH)"

Ok, excellent.

Does it work while linking libraries too ?

Thanks.

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Something like TProcess.Environment for libraries ?

fredvs
Re-hello.

Is it cross-platform (does it work for Windows too) ?

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Something like TProcess.Environment for libraries ?

Jonas Maebe-3
In reply to this post by fredvs
On 30/01/17 12:27, fredvs wrote:
> Hello Jonas.
>
>>  -k-rpath -k$(DEFAULT_LIB_INSTALL_PATH), or "-k-rpath
>> $(DEFAULT_LIB_INSTALL_PATH)"
>
> Ok, excellent.
>
> Does it work while linking libraries too ?

Yes.

 > Is it cross-platform (does it work for Windows too) ?

No. It doesn't work for OS X either. On neither of those platforms that
option would make any sense, as they use different ways to look for
shared libraries.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Something like TProcess.Environment for libraries ?

fredvs
Many thanks for your light Jonas.

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Something like TProcess.Environment for libraries ?

fredvs
Huh, sorry to come back with this but...

Loadlibrary() for a sub-dependency works. ;-)

For example:
libopusfile.so has libopus.so as dependency.

So, before to loadlibrary(libopusfile.so), do --> loadlibrary(libopus.so), keeping the original file-name.

Example:

loadlibrary(/directory/of/libopus.so) ; // do not change file-name.
loadlibrary(/directory/of/Mylibopusfile.so) ; // here you may change the file-name.

PS: It works for how many sub-dependencies the main library has (but you have to respect the order of loading).

Yep ;-)

Fre;D
Many thanks ;-)
Loading...