Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] dnsmasq: fix static linking
Date: Tue, 4 Mar 2014 19:29:27 +0100	[thread overview]
Message-ID: <20140304192927.4c1cd475@skate> (raw)
In-Reply-To: <1393946074-32602-1-git-send-email-Vincent.Riera@imgtec.com>

Dear Vicente Olivert Riera,

On Tue, 4 Mar 2014 15:14:34 +0000, Vicente Olivert Riera wrote:
> Append -pthread to LIBS to fix a static linking error like this one:
> 
> /home/test/test/2/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/lib/libdbus-1.a(libdbus_1_la-dbus-sysdeps-pthread.o):
> In function `_dbus_platform_cmutex_new':
> dbus-sysdeps-pthread.c:(.text+0x30): undefined reference to
> `pthread_mutex_init'
> 
> Fixes:
>    http://autobuild.buildroot.net/results/161/161446dde7e8e774773eb2b34fd555f5ac22dd02/
> 
> Reviewed-by: Markos Chandras <Markos.Chandras@imgtec.com>
> Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>

Thanks, but I don't think it's the best fix for the problem.

>  ifeq ($(BR2_PACKAGE_DBUS),y)
>  	DNSMASQ_DEPENDENCIES += host-pkgconf dbus
> +	DNSMASQ_LIBS += $(if $(BR2_PREFER_STATIC_LIB),-pthread)
>  endif

dnsmasq properly uses pkg-config to find which library to link against,
and the dbus-1.pc properly lists -lrt and -lpthread in Libs.private
(i.e libraries needed in the link when linking statically).

The problem is just that the dnsmasq Makefile does not call pkg-config
with the --static option when being built statically. Compare the
output of:

$ ./output/host/usr/bin/pkg-config --libs dbus-1
-L/home/thomas/projets/buildroot/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/lib -ldbus-1

against the output of:

$ ./output/host/usr/bin/pkg-config --static --libs dbus-1
-L/home/thomas/projets/buildroot/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/lib -ldbus-1 -lpthread -lrt

Best regards,

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

      reply	other threads:[~2014-03-04 18:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04 15:14 [Buildroot] [PATCH] dnsmasq: fix static linking Vicente Olivert Riera
2014-03-04 18:29 ` Thomas Petazzoni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140304192927.4c1cd475@skate \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox