Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH bluez-utils] Link mcaptest with -lrt
@ 2014-12-29 12:38 Thomas Petazzoni
  2014-12-29 17:40 ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2014-12-29 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Thomas Petazzoni

The mcaptest tool uses the profiles/health/mcap.c source file, which
calls clock_getres(). This function is defined in librt, so mcaptest
should be linked against librt, otherwise one gets link failures such
as:

ld: profiles/health/mcap.o: undefined reference to symbol 'clock_getres@@GLIBC_2.2.5'
ld: note: 'clock_getres@@GLIBC_2.2.5' is defined in DSO [...]/sysroot/lib64/librt.so.1 so try adding it to the linker command line
[...]/sysroot/lib64/librt.so.1: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
Makefile:4184: recipe for target 'tools/mcaptest' failed

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 Makefile.tools | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.tools b/Makefile.tools
index bc827fe..178b773 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -195,7 +195,7 @@ tools_mcaptest_SOURCES = tools/mcaptest.c \
 				btio/btio.h btio/btio.c \
 				src/log.c src/log.h \
 				profiles/health/mcap.h profiles/health/mcap.c
-tools_mcaptest_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+tools_mcaptest_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@ -lrt
 
 dist_man_MANS += tools/hciattach.1 tools/hciconfig.1 \
 			tools/hcitool.1 tools/hcidump.1 \
-- 
2.1.0


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

* Re: [PATCH bluez-utils] Link mcaptest with -lrt
  2014-12-29 12:38 [PATCH bluez-utils] Link mcaptest with -lrt Thomas Petazzoni
@ 2014-12-29 17:40 ` Marcel Holtmann
  2014-12-29 22:22   ` Thomas Petazzoni
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2014-12-29 17:40 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: linux-bluetooth

Hi Thomas,

> The mcaptest tool uses the profiles/health/mcap.c source file, which
> calls clock_getres(). This function is defined in librt, so mcaptest
> should be linked against librt, otherwise one gets link failures such
> as:
> 
> ld: profiles/health/mcap.o: undefined reference to symbol 'clock_getres@@GLIBC_2.2.5'
> ld: note: 'clock_getres@@GLIBC_2.2.5' is defined in DSO [...]/sysroot/lib64/librt.so.1 so try adding it to the linker command line
> [...]/sysroot/lib64/librt.so.1: could not read symbols: Invalid operation
> collect2: error: ld returned 1 exit status
> Makefile:4184: recipe for target 'tools/mcaptest' failed

the manpage clearly states to only link against -lrt when using glibc versions before 2.17. If we want to support older glibc, then this might need to be conditional via a configure test.

Regards

Marcel


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

* Re: [PATCH bluez-utils] Link mcaptest with -lrt
  2014-12-29 17:40 ` Marcel Holtmann
@ 2014-12-29 22:22   ` Thomas Petazzoni
  2014-12-29 22:22     ` [PATCHv2] Link mcaptest with -lrt when needed Thomas Petazzoni
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2014-12-29 22:22 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Dear Marcel Holtmann,

On Mon, 29 Dec 2014 09:40:04 -0800, Marcel Holtmann wrote:
> Hi Thomas,
> 
> > The mcaptest tool uses the profiles/health/mcap.c source file, which
> > calls clock_getres(). This function is defined in librt, so mcaptest
> > should be linked against librt, otherwise one gets link failures such
> > as:
> > 
> > ld: profiles/health/mcap.o: undefined reference to symbol 'clock_getres@@GLIBC_2.2.5'
> > ld: note: 'clock_getres@@GLIBC_2.2.5' is defined in DSO [...]/sysroot/lib64/librt.so.1 so try adding it to the linker command line
> > [...]/sysroot/lib64/librt.so.1: could not read symbols: Invalid operation
> > collect2: error: ld returned 1 exit status
> > Makefile:4184: recipe for target 'tools/mcaptest' failed
> 
> the manpage clearly states to only link against -lrt when using glibc
> versions before 2.17. If we want to support older glibc, then this
> might need to be conditional via a configure test.

Ah, yes, indeed. v2 of the patch follows. Thanks for the review!

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

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

* [PATCHv2] Link mcaptest with -lrt when needed
  2014-12-29 22:22   ` Thomas Petazzoni
@ 2014-12-29 22:22     ` Thomas Petazzoni
  2015-02-11 15:33       ` Szymon Janc
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2014-12-29 22:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Marcel Holtmann, Thomas Petazzoni

The mcaptest tool uses the profiles/health/mcap.c source file, which
calls clock_getres(). This function is defined in librt in some C
libraries, so mcaptest should be linked against librt when needed,
otherwise one gets link failures such as:

ld: profiles/health/mcap.o: undefined reference to symbol 'clock_getres@@GLIBC_2.2.5'
ld: note: 'clock_getres@@GLIBC_2.2.5' is defined in DSO [...]/sysroot/lib64/librt.so.1 so try adding it to the linker command line
[...]/sysroot/lib64/librt.so.1: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
Makefile:4184: recipe for target 'tools/mcaptest' failed

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 Makefile.tools | 2 +-
 configure.ac   | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile.tools b/Makefile.tools
index bc827fe..fef3db5 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -195,7 +195,7 @@ tools_mcaptest_SOURCES = tools/mcaptest.c \
 				btio/btio.h btio/btio.c \
 				src/log.c src/log.h \
 				profiles/health/mcap.h profiles/health/mcap.c
-tools_mcaptest_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+tools_mcaptest_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@ @RT_LIBS@
 
 dist_man_MANS += tools/hciattach.1 tools/hciconfig.1 \
 			tools/hcitool.1 tools/hcidump.1 \
diff --git a/configure.ac b/configure.ac
index 4739c10..b0afba6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,11 @@ AC_CHECK_LIB(pthread, pthread_create, dummy=yes,
 AC_CHECK_LIB(dl, dlopen, dummy=yes,
 			AC_MSG_ERROR(dynamic linking loader is required))
 
+AC_SEARCH_LIBS([clock_getres], [rt],
+			[test "$ac_cv_search_clock_getres" = "none required" ||
+			RT_LIBS=$ac_cv_search_clock_getres])
+AC_SUBST([RT_LIBS])
+
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
 				AC_MSG_ERROR(GLib >= 2.28 is required))
 AC_SUBST(GLIB_CFLAGS)
-- 
2.1.0

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

* Re: [PATCHv2] Link mcaptest with -lrt when needed
  2014-12-29 22:22     ` [PATCHv2] Link mcaptest with -lrt when needed Thomas Petazzoni
@ 2015-02-11 15:33       ` Szymon Janc
  0 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2015-02-11 15:33 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: linux-bluetooth, Marcel Holtmann

Hi Thomas,

On Monday 29 of December 2014 23:22:54 Thomas Petazzoni wrote:
> The mcaptest tool uses the profiles/health/mcap.c source file, which
> calls clock_getres(). This function is defined in librt in some C
> libraries, so mcaptest should be linked against librt when needed,
> otherwise one gets link failures such as:
> 
> ld: profiles/health/mcap.o: undefined reference to symbol 'clock_getres@@GLIBC_2.2.5'
> ld: note: 'clock_getres@@GLIBC_2.2.5' is defined in DSO [...]/sysroot/lib64/librt.so.1 so try adding it to the linker command line
> [...]/sysroot/lib64/librt.so.1: could not read symbols: Invalid operation
> collect2: error: ld returned 1 exit status
> Makefile:4184: recipe for target 'tools/mcaptest' failed
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  Makefile.tools | 2 +-
>  configure.ac   | 5 +++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.tools b/Makefile.tools
> index bc827fe..fef3db5 100644
> --- a/Makefile.tools
> +++ b/Makefile.tools
> @@ -195,7 +195,7 @@ tools_mcaptest_SOURCES = tools/mcaptest.c \
>  				btio/btio.h btio/btio.c \
>  				src/log.c src/log.h \
>  				profiles/health/mcap.h profiles/health/mcap.c
> -tools_mcaptest_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
> +tools_mcaptest_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@ @RT_LIBS@
>  
>  dist_man_MANS += tools/hciattach.1 tools/hciconfig.1 \
>  			tools/hcitool.1 tools/hcidump.1 \
> diff --git a/configure.ac b/configure.ac
> index 4739c10..b0afba6 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -54,6 +54,11 @@ AC_CHECK_LIB(pthread, pthread_create, dummy=yes,
>  AC_CHECK_LIB(dl, dlopen, dummy=yes,
>  			AC_MSG_ERROR(dynamic linking loader is required))
>  
> +AC_SEARCH_LIBS([clock_getres], [rt],
> +			[test "$ac_cv_search_clock_getres" = "none required" ||
> +			RT_LIBS=$ac_cv_search_clock_getres])
> +AC_SUBST([RT_LIBS])
> +
>  PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
>  				AC_MSG_ERROR(GLib >= 2.28 is required))
>  AC_SUBST(GLIB_CFLAGS)

This seems to got lost in traffic.
Since it doesn't apply anymore you would have to rebase it.

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2015-02-11 15:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-29 12:38 [PATCH bluez-utils] Link mcaptest with -lrt Thomas Petazzoni
2014-12-29 17:40 ` Marcel Holtmann
2014-12-29 22:22   ` Thomas Petazzoni
2014-12-29 22:22     ` [PATCHv2] Link mcaptest with -lrt when needed Thomas Petazzoni
2015-02-11 15:33       ` Szymon Janc

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