Skip to contentSkip to conversation

package/log4cpp: add -lpthread to LIBS

PATCH New Fabrice Fontaine 2 participants 2 messages May 11, 2019 – May 13, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/log4cpp: add -lpthread to LIBS

linknx fails to build with log4cpp because log4cpp does not add -lpthread to its log4cpp.pc file:

/home/buildroot/autobuild/instance-0/output/host/bin/mipsel-linux-g++ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -o linknx linknx.o logger.o ruleserver.o objectcontroller.o eibclient.o threads.o timermanager.o persistentstorage.o xmlserver.o smsgateway.o emailgateway.o knxconnection.o services.o suncalc.o luacondition.o ioport.o ../ticpp/libticpp.a -L/home/buildroot/autobuild/instance-0/output/host/mipsel-buildroot-linux-gnu/sysroot/usr/bin/../../usr/lib -lpthsem -L/home/buildroot/autobuild/instance-0/output/host/bin/../mipsel-buildroot-linux-gnu/sysroot/usr/lib -llog4cpp -lm
/home/buildroot/autobuild/instance-0/output/host/mipsel-buildroot-linux-gnu/sysroot/usr/bin/../../usr/lib/liblog4cpp.so: undefined reference to `pthread_key_create'

Help log4cpp to find this dependency by adding it to LIBS

Fixes:
- http://autobuild.buildroot.org/results/1863f8f27041bc15ca68e786ba3b8e4764c40574

---
 package/log4cpp/log4cpp.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/log4cpp/log4cpp.mk +1 -1
index 8664a54385..527ad49e53 100644
@@ -12,7 +12,7 @@ LOG4CPP_SUBDIR = log4cpp
 LOG4CPP_LICENSE = LGPL-2.1+
 LOG4CPP_LICENSE_FILES = log4cpp/COPYING
 LOG4CPP_INSTALL_STAGING = YES
-LOG4CPP_CONF_OPTS = --enable-doxygen=no --enable-dot=no
+LOG4CPP_CONF_OPTS = --enable-doxygen=no --enable-dot=no LIBS=-lpthread
 # needed to fix broken configure script
 LOG4CPP_AUTORECONF = YES
 LOG4CPP_AUTORECONF_OPTS = -I m4
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/log4cpp: add -lpthread to LIBS

Hello Fabrice,

Thanks for your investigation on this issue.

package/log4cpp/log4cpp.mk LOG4CPP_SUBDIR = log4cpp · line 15

Quoted 10 lines · On Sat, 11 May 2019 12:10:48 +0200 Fabrice Fontaine…
package/log4cpp/log4cpp.mk +1 -1
index 8664a54385..527ad49e53 100644
@@ -12,7 +12,7 @@ LOG4CPP_SUBDIR = log4cpp
 LOG4CPP_LICENSE = LGPL-2.1+
 LOG4CPP_LICENSE_FILES = log4cpp/COPYING
 LOG4CPP_INSTALL_STAGING = YES
-LOG4CPP_CONF_OPTS = --enable-doxygen=no --enable-dot=no
+LOG4CPP_CONF_OPTS = --enable-doxygen=no --enable-dot=no LIBS=-lpthread

I don't think this is the right fix for the problem. Indeed, to me log4cpp.pc is already correct:

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

Name: log4cpp
Description: C++ library for flexible logging, modeled after Log4j
Version: 1.1
Libs: -L${libdir} -llog4cpp
Cflags: -I${includedir} -pthread -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os

See the -pthread in Cflags ? This should be sufficient.

I believe the problem rather lies inside the src/Makefile.am of linknx. It adds LOG4CPP_CFLAGS to AM_CPPFLAGS. But AM_CPPFLAGS are only used when the pre-processor is involved, which is not the case at link time.

If you move $(LOG4CPP_CFLAGS) from AM_CPPFLAGS to AM_CXXFLAGS, it fixes the problem. I believe this is a more correct fix, and is upstreamable to linknx.

Could you cook such a patch ? :-)

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com