Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] On the usefulness of .la files and .pc files
@ 2009-03-18 16:44 Thomas Petazzoni
  2009-03-18 17:24 ` Sven Neumann
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2009-03-18 16:44 UTC (permalink / raw)
  To: buildroot

Hi,

My question is slightly out of topic because it doesn't concern
Buildroot specifically, but as it concerns the autotools build system,
I thought I could share it with the list.

When compiling libraries using libtool, a .la file gets installed
in /usr/lib. It defines several informations such as :

 * The names of the library ;
 * The dependencies of the library ;
 * The directory where the library is installed ;
 * A few other informations.

Many libraries also install a .pc file in /usr/lib/pkgconfig/. It also
describe the dependencies, the library name, the flags to compile new
applications/libraries on top of the library, etc.

I can't figure out why there are two different mechanisms. From my
understanding, both of these files serve the same purpose : describe
how new applications/libraries can be built against the library. Am I
wrong ?

Let's take the example of libpng. It installs :

 * /usr/lib/libpng12.la, with things like

dlname='libpng12.so.0'
dependency_libs='-L/home/thomas/thirdparty/staging/usr/lib/ -lz -lm'
libdir='/usr/lib'

 * /usr/lib/pkgconfig/libpng12.pc, with :

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/libpng12

Name: libpng
Description: Loads and saves PNG files
Version: 1.2.35
Libs: -L${libdir} -lpng12
Libs.private: -lz -lm 
Cflags: -I${includedir} 

 * /usr/bin/libpng12-config, which is a shell script that also
   basically gives the same information.

While I understand that /usr/bin/libpng12-config is a legacy script
that predates the widespread usage of pkg-config, I can't figure out
why both the .pc file and .la file are needed.

Any insight ?

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com

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

* [Buildroot] On the usefulness of .la files and .pc files
  2009-03-18 16:44 [Buildroot] On the usefulness of .la files and .pc files Thomas Petazzoni
@ 2009-03-18 17:24 ` Sven Neumann
  2009-03-18 18:47   ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Neumann @ 2009-03-18 17:24 UTC (permalink / raw)
  To: buildroot

Hi,

On Wed, 2009-03-18 at 17:44 +0100, Thomas Petazzoni wrote:

> When compiling libraries using libtool, a .la file gets installed
> in /usr/lib. It defines several informations such as :
> 
>  * The names of the library ;
>  * The dependencies of the library ;
>  * The directory where the library is installed ;
>  * A few other informations.

This tells libtool how to link a particular library. This is mainly
useful on platforms that need libraries to be explicitly linked. On
Linux this is actually not needed and you may safely remove those files.

> Many libraries also install a .pc file in /usr/lib/pkgconfig/. It also
> describe the dependencies, the library name, the flags to compile new
> applications/libraries on top of the library, etc.

This gives hints on to compile stuff against the library. It is much
more useful than the .la files as it allows to easily check for the
presence of a library, it's version, dependencies and what compiler
flags are needed.


Sven

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

* [Buildroot] On the usefulness of .la files and .pc files
  2009-03-18 17:24 ` Sven Neumann
@ 2009-03-18 18:47   ` Thomas Petazzoni
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2009-03-18 18:47 UTC (permalink / raw)
  To: buildroot

Hi Sven,

Le Wed, 18 Mar 2009 18:24:45 +0100,
Sven Neumann <s.neumann@phase-zero.de> a ?crit :

> This tells libtool how to link a particular library.

What do you mean by ? link a particular library ? :

 1) How to create the library itself (i.e, the .so file)

 2) How to link an application or another library *against* the
    considered library ?

> This is mainly useful on platforms that need libraries to be
> explicitly linked.

By ? explicitly linked ?, you mean that when compiling library A, that
depends on B, which itself depends on C, you need to use -lB -lC, while
on Linux, giving -lB is enough ?

> On Linux this is actually not needed and you may safely remove those
> files.

So, why do we keep them and even patch them in Buildroot (see the
$(BUILD_DIR)/%/.stamp_staging_installed: rule in
package/Makefile.autotools.in). If the .la files are not patched (with
the modification of the libdir variable), then the link step of other
libraries or applications depending on the library fail. So the .la
files are clearly used.

> > Many libraries also install a .pc file in /usr/lib/pkgconfig/. It
> > also describe the dependencies, the library name, the flags to
> > compile new applications/libraries on top of the library, etc.
> 
> This gives hints on to compile stuff against the library. It is much
> more useful than the .la files as it allows to easily check for the
> presence of a library, it's version, dependencies and what compiler
> flags are needed.

Ok. This is understood.

Thanks for your clarification!

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com

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

end of thread, other threads:[~2009-03-18 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 16:44 [Buildroot] On the usefulness of .la files and .pc files Thomas Petazzoni
2009-03-18 17:24 ` Sven Neumann
2009-03-18 18:47   ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox