All of lore.kernel.org
 help / color / mirror / Atom feed
* Adding line to ld.so.conf
@ 2011-11-21 15:35 Marc Ferland
  2011-11-21 16:04 ` Khem Raj
  2011-12-02 16:08 ` Michael E Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Marc Ferland @ 2011-11-21 15:35 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 119 bytes --]

Hi,

What's the proper way to add a line to the ld.so.conf file for a new
library I am adding?

Regards,

Marc

[-- Attachment #2: Type: text/html, Size: 138 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding line to ld.so.conf
  2011-11-21 15:35 Adding line to ld.so.conf Marc Ferland
@ 2011-11-21 16:04 ` Khem Raj
  2011-11-21 16:17   ` Marc Ferland
  2011-12-02 16:08 ` Michael E Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Khem Raj @ 2011-11-21 16:04 UTC (permalink / raw)
  To: Marc Ferland; +Cc: yocto

On Mon, Nov 21, 2011 at 7:35 AM, Marc Ferland <marc.ferland@gmail.com> wrote:
> Hi,
>
> What's the proper way to add a line to the ld.so.conf file for a new library
> I am adding?
>

if the libraries is in standard paths you dont have to add it but if
its in a special path
then just add the absolute path to the library e.g. /opt/lib if your
library is in /opt/lib
and then run ldconfig

> Regards,
>
> Marc
>
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding line to ld.so.conf
  2011-11-21 16:04 ` Khem Raj
@ 2011-11-21 16:17   ` Marc Ferland
  2011-11-21 16:39     ` Mark Hatle
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Ferland @ 2011-11-21 16:17 UTC (permalink / raw)
  To: Khem Raj; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

On Mon, Nov 21, 2011 at 11:04 AM, Khem Raj <raj.khem@gmail.com> wrote:

> On Mon, Nov 21, 2011 at 7:35 AM, Marc Ferland <marc.ferland@gmail.com>
> wrote:
> > Hi,
> >
> > What's the proper way to add a line to the ld.so.conf file for a new
> library
> > I am adding?
> >
>
> if the libraries is in standard paths you dont have to add it but if
> its in a special path
> then just add the absolute path to the library e.g. /opt/lib if your
> library is in /opt/lib
> and then run ldconfig
>

What I meant was how to do it in a recipe file. I don't want to modify
ld.so.conf and run ldconfig each time I create a new image.

Regards,

Marc

[-- Attachment #2: Type: text/html, Size: 1041 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding line to ld.so.conf
  2011-11-21 16:17   ` Marc Ferland
@ 2011-11-21 16:39     ` Mark Hatle
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Hatle @ 2011-11-21 16:39 UTC (permalink / raw)
  To: yocto

On 11/21/11 10:17 AM, Marc Ferland wrote:
> On Mon, Nov 21, 2011 at 11:04 AM, Khem Raj <raj.khem@gmail.com
> <mailto:raj.khem@gmail.com>> wrote:
>
>     On Mon, Nov 21, 2011 at 7:35 AM, Marc Ferland <marc.ferland@gmail.com
>     <mailto:marc.ferland@gmail.com>> wrote:
>      > Hi,
>      >
>      > What's the proper way to add a line to the ld.so.conf file for a new library
>      > I am adding?
>      >
>
>     if the libraries is in standard paths you dont have to add it but if
>     its in a special path
>     then just add the absolute path to the library e.g. /opt/lib if your
>     library is in /opt/lib
>     and then run ldconfig
>
>
> What I meant was how to do it in a recipe file. I don't want to modify
> ld.so.conf and run ldconfig each time I create a new image.

There are issues with playing with ld.so.conf when doing a cross image 
generation.  ldconfig doesn't always work during the rootfs process, most people 
don't notice since it's simply not necessary to be run in most cases!

Lets assume for a minute that it does work in all cases.. (I'll explain a better 
solution in a bit.)

You would want a post install script that:

checks to see if the ld.so.conf already contains the line you need, if it does 
NOT, you would then add the line to the ld.so.conf file.  Then you would run 
ldconfig within the post install script -- if you are not doing a cross install. 
  (Cross installs automatically attempt to run ldconfig.)

Something like...

grep -q /opt/lib ${D}/etc/ld.so.conf || echo /opt/lib >> /etc/ld.so.conf

if [ -z "${D}" ]; then
  ldconfig
fi


The above may work in your local projects, but will likely be rejected from 
submissions to the upstream project as being too fragile.

.....

But there is a better way to do this and avoid using ldconfig.  ldconfig was 
designed to be an optimization, but instead it's turned into a hack to cover up 
mistakes.  It's primary use seems to be to cover up when people forget to create 
symlinks and/or don't specify an SONAME within a library.  The secondary use is 
to add library information for libraries residing in non-standard locations... 
and the tertiary use is to simplify the lookup of the packages to avoid 
iterating over a filesystem.

Instead of using ldconfig, inform the application on the locations of the 
non-standard items.  This will then add them to the search path and ldconfig 
will no longer be necessary for a functional system, and instead become the 
optimization it was originally designed to be.

One way to do this, when you are repackaging something you didn't create and 
only have the binaries for, is to create a wrapper script that sets 
"LD_LIBRARY_PATH=<path to library>" and then executes the action binary..

or

If you are doing the compilation, use a built-in RPATH to specify where your 
application libraries exist.  See: http://itee.uq.edu.au/~daniel/using_origin/ 
for a good explanation of what to pass to the linker and how to use "$ORIGIN" to 
make it easier -- and your application relocatable on the target.  But in short 
you hard-code at compile time the location of your libraries based on the 
location of your executables.

--Mark

> Regards,
>
> Marc
>
>
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding line to ld.so.conf
  2011-11-21 15:35 Adding line to ld.so.conf Marc Ferland
  2011-11-21 16:04 ` Khem Raj
@ 2011-12-02 16:08 ` Michael E Brown
  2011-12-02 16:27   ` Mark Hatle
  1 sibling, 1 reply; 6+ messages in thread
From: Michael E Brown @ 2011-12-02 16:08 UTC (permalink / raw)
  To: Marc Ferland; +Cc: yocto@yoctoproject.org

On Mon, 2011-11-21 at 09:35 -0600, Marc Ferland wrote:
> Hi,
> 
> What's the proper way to add a line to the ld.so.conf file for a new
> library I am adding?

Does yocto support /etc/ld.so.conf.d/ (like every other distro out there
from the past 7 years or so?)

You could just drop a file into that directory with the lines you want
rather than editing the global file.
--
Michael



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding line to ld.so.conf
  2011-12-02 16:08 ` Michael E Brown
@ 2011-12-02 16:27   ` Mark Hatle
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Hatle @ 2011-12-02 16:27 UTC (permalink / raw)
  To: yocto

On 12/2/11 10:08 AM, Michael E Brown wrote:
> On Mon, 2011-11-21 at 09:35 -0600, Marc Ferland wrote:
>> Hi,
>>
>> What's the proper way to add a line to the ld.so.conf file for a new
>> library I am adding?
>
> Does yocto support /etc/ld.so.conf.d/ (like every other distro out there
> from the past 7 years or so?)
>
> You could just drop a file into that directory with the lines you want
> rather than editing the global file.

This is accomplished by having the following line in the /etc/ld.so.conf file.

include ld.so.conf.d/*.conf

However, this then still requires the file to exist on the target filesystem. 
I've got many systems where ld.so.conf simply doesn't exist, nor do I want it to.

See my previous reply on a better was to resolve the issue using rpath and/or 
proper soname handling inside of the libraries.

--Mark


> --
> Michael
>
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-12-02 16:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-21 15:35 Adding line to ld.so.conf Marc Ferland
2011-11-21 16:04 ` Khem Raj
2011-11-21 16:17   ` Marc Ferland
2011-11-21 16:39     ` Mark Hatle
2011-12-02 16:08 ` Michael E Brown
2011-12-02 16:27   ` Mark Hatle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.