Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-01

Something like TProcess.Environment for libraries ?

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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 ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Something-like-TProcess-Environment-for-libraries-tp5727468.html Sent from the Free Pascal - General mailing list .

Reply by email

fredvs
to 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 ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Something-like-TProcess-Environment-for-libraries-tp5727468p5727499.html Sent from the Free Pascal - General mailing list .

Reply by email

Jonas Maebe
to fredvs
fredvs wrote 11 lines
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

Reply by email

Jonas Maebe
to fredvs: Hello Jonas. Ok, excellent. Does it work while linking libraries too ? Thanks. Fre;D -----
fredvs wrote 8 lines
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

Reply by email

fredvs
to 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 ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Something-like-TProcess-Environment-for-libraries-tp5727468p5728041.html Sent from the Free Pascal - General mailing list .

Reply by email