[Buildroot] [PATCH 1/1] libcap: fix static linking issue

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Wed Oct 16 16:09:46 UTC 2013


Dear Romain Naour,

On Sun, 13 Oct 2013 21:44:08 +0200, Romain Naour wrote:

> You're right, the static lib isn’t built with -fPIC.
> But the libcap build system build the static and shared libraries,
> even if you don't want one of them.
> 
> The build failure [1] is caused by the missing -fPIC during the build of libcap.so.2.22
> 
> So, we may add -fPIC if BR2_PREFER_STATIC_LIB=y and the shared lib is build correctly
> (ok it's weird)
> Or add a patch for enable/disable separately the static/shared build.

If BR2_PREFER_STATIC_LIB=y, then not shared library should be built at
all. Even though the naming of the option doesn't make it clear for the
moment.

And therefore, when BR2_PREFER_STATIC_LIB=y, passing -fPIC should not
be needed, as we're building only static libraries.

I had a quick look at libcap, and we can easily build only the static
or shared library by doing the $(MAKE) only in $(@D)/libcap, and using
the libcap.a and libcap.so targets. But the install target is not really
adapted to that, so we would have to install things manually.

Maybe a little patch to the libcap/Makefile which understands
BUILD_STATIC and BUILD_SHARED variables would be good.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


More information about the buildroot mailing list