| Thread overview | ||||||||
|---|---|---|---|---|---|---|---|---|
|
April 17, 2012 Shared libraries under linux | ||||
|---|---|---|---|---|
| ||||
Just a tip for everybody, but Under Linux, you can do a lot with the Linker commands you know those -L ones, besides being able to link with shared, you can also specify where the ELF binary will look to find your D shared library, by using -L-r which embeds a search path in your ELF binary, handy for updateable libraries, or a plugin system. I have a complete example somewhere on my laptop if anyone is interested. This is a native feature of ld so it should work almost anywhere.
--
alexhairyman <alexhairyman@gmail.com>
| ||||
April 17, 2012 Re: Shared libraries under linux | ||||
|---|---|---|---|---|
| ||||
Posted in reply to alexhairyman | On Tuesday, 17 April 2012 at 00:41:46 UTC, alexhairyman wrote:
> Just a tip for everybody, but Under Linux, you can do a lot with the Linker commands you know those -L ones, besides being able to link with shared, you can also specify where the ELF binary will look to find your D shared library, by using -L-r which embeds a search path in your ELF binary, handy for updateable libraries, or a plugin system. I have a complete example somewhere on my laptop if anyone is interested. This is a native feature of ld so it should work almost anywhere.
For a plugin system, wouldn't you use dlopen and link to dl?
Also, you might as well use LD_LIBRARY_PATH and rpath-stripped libs/bins instead which seems like the cleaner solution to me.
| |||
April 17, 2012 Re: Shared libraries under linux | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Sven-Hendrik Haase | On Tue, 17 Apr 2012 02:46:28 +0200 "Sven-Hendrik Haase" <sh@lutzhaase.com> wrote: > On Tuesday, 17 April 2012 at 00:41:46 UTC, alexhairyman wrote: > > Just a tip for everybody, but Under Linux, you can do a lot with the Linker commands you know those -L ones, besides being able to link with shared, you can also specify where the ELF binary will look to find your D shared library, by using -L-r which embeds a search path in your ELF binary, handy for updateable libraries, or a plugin system. I have a complete example somewhere on my laptop if anyone is interested. This is a native feature of ld so it should work almost anywhere. > > For a plugin system, wouldn't you use dlopen and link to dl? > > Also, you might as well use LD_LIBRARY_PATH and rpath-stripped libs/bins instead which seems like the cleaner solution to me. True, that was an excited blurb of misinformation I gave there, but rpath keeps you from having to use LD_LIBRARY_PATH which would require you to add a script to first set, then call the application, and while it is not much of a burden, it makes things a little bit easier to use. And is there a way to use libdl in a "D-ish" way? I remember the Old c++ way being a bit sloppy but not at all bad, simply requiring you to create a function that returned a class (if my memory decides to work).And the DDl project is dead for now, and shows little hope of revival. If someone could point me in the direction of a similar library I would very much appreciate it! And yes, the plugin system would be nearly impossible (if not outright) -- alexhairyman <alexhairyman@gmail.com> | |||
April 17, 2012 Re: Shared libraries under linux | ||||
|---|---|---|---|---|
| ||||
Posted in reply to alexhairyman | alexhairyman wrote: > On Tue, 17 Apr 2012 02:46:28 +0200 > "Sven-Hendrik Haase" <sh@lutzhaase.com> wrote: > > > On Tuesday, 17 April 2012 at 00:41:46 UTC, alexhairyman wrote: > > > Just a tip for everybody, but Under Linux, you can do a lot with the Linker commands you know those -L ones, besides being able to link with shared, you can also specify where the ELF binary will look to find your D shared library, by using -L-r which embeds a search path in your ELF binary, handy for updateable libraries, or a plugin system. I have a complete example somewhere on my laptop if anyone is interested. This is a native feature of ld so it should work almost anywhere. > > > > For a plugin system, wouldn't you use dlopen and link to dl? > > > > Also, you might as well use LD_LIBRARY_PATH and rpath-stripped libs/bins instead which seems like the cleaner solution to me. > > True, that was an excited blurb of misinformation I gave there, but rpath keeps you from having to use LD_LIBRARY_PATH which would require you to add a script to first set, then call the application, and while it is not much of a burden, it makes things a little bit easier to use. And is there a way to use libdl in a "D-ish" way? I remember the Old c++ way being a bit sloppy but not at all bad, simply requiring you to create a function that returned a class (if my memory decides to work).And the DDl project is dead for now, and shows little hope of revival. If someone could point me in the direction of a similar library I would very much appreciate it! And yes, the plugin system would be nearly impossible (if not outright) Does this http://jkm.github.com/ddl/ddl.html work for you? I welcome any kind of feedback. Jens | |||
April 17, 2012 Re: Shared libraries under linux | ||||
|---|---|---|---|---|
| ||||
Posted in reply to alexhairyman | On Tue, 17 Apr 2012 02:41:45 +0200, alexhairyman <alexhairyman@gmail.com> wrote: > Just a tip for everybody, but Under Linux, you can do a lot with the Linker commands you know those -L ones, besides being able to link with shared, you can also specify where the ELF binary will look to find your D shared library, by using -L-r which embeds a search path in your ELF binary, handy for updateable libraries, or a plugin system. I have a complete example somewhere on my laptop if anyone is interested. This is a native feature of ld so it should work almost anywhere. > http://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath | |||
April 17, 2012 Re: Shared libraries under linux | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jens Mueller | On Tuesday, 17 April 2012 at 07:28:14 UTC, Jens Mueller wrote:
> alexhairyman wrote:
>> On Tue, 17 Apr 2012 02:46:28 +0200
>> "Sven-Hendrik Haase" <sh@lutzhaase.com> wrote:
>>
>> > On Tuesday, 17 April 2012 at 00:41:46 UTC, alexhairyman wrote:
>> > > Just a tip for everybody, but Under Linux, you can do a lot with the Linker commands you know those -L ones, besides being able to link with shared, you can also specify where the ELF binary will look to find your D shared library, by using -L-r which embeds a search path in your ELF binary, handy for updateable libraries, or a plugin system. I have a complete example somewhere on my laptop if anyone is interested. This is a native feature of ld so it should work almost anywhere.
>> >
>> > For a plugin system, wouldn't you use dlopen and link to dl?
>> >
>> > Also, you might as well use LD_LIBRARY_PATH and rpath-stripped libs/bins instead which seems like the cleaner solution to me.
>>
>> True, that was an excited blurb of misinformation I gave there, but
>> rpath keeps you from having to use LD_LIBRARY_PATH which would require
>> you to add a script to first set, then call the application, and while
>> it is not much of a burden, it makes things a little bit easier to
>> use. And is there a way to use libdl in a "D-ish" way? I remember the
>> Old c++ way being a bit sloppy but not at all bad, simply requiring
>> you to create a function that returned a class (if my memory decides
>> to work).And the DDl project is dead for now, and shows little hope of
>> revival. If someone could point me in the direction of a similar
>> library I would very much appreciate it! And yes, the plugin system
>> would be nearly impossible (if not outright)
>
> Does this http://jkm.github.com/ddl/ddl.html work for you? I welcome any
> kind of feedback.
>
> Jens
O_o YES! Will definitely check this out!
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply