Re: sd-bus.h not found even with DEPENDS += "systemd"
Bel Hadj Salem Talel <bhstalel@...>
HI Again,
The systemd issue is solved by installing the libsystemd in my native host, but I got another problem linking the lib with "ld" :
| /media/talel/data/menzu-zeus/menzu/tmp/work/aarch64-poky-linux/wirepas-sink-tool/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/ld: c-mesh-api/lib/build/mesh_api_lib.a(logger.o): Relocations in generic ELF (EM: 62)
| /media/talel/data/menzu-zeus/menzu/tmp/work/aarch64-poky-linux/wirepas-sink-tool/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/ld: c-mesh-api/lib/build/mesh_api_lib.a(logger.o): Relocations in generic ELF (EM: 62)
| /media/talel/data/menzu-zeus/menzu/tmp/work/aarch64-poky-linux/wirepas-sink-tool/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/ld: c-mesh-api/lib/build/mesh_api_lib.a: error adding symbols: file in wrong format
| collect2: error: ld returned 1 exit status
| makefile:102: recipe for target 'build/sinkService' failed
Here is the Makefile:
---------------------------
# Makefile for Wirepas Dbus Sink module
# Toolchain
CC ?= gcc
AS ?= as
LD ?= ld
AR ?= ar
# Paths, including trailing path separator
SOURCEPREFIX := source/
BUILDPREFIX := build/
# This example needs the mesh lib
MESH_LIB_FOLDER := c-mesh-api/lib/
MESH_LIB := $(MESH_LIB_FOLDER)build/mesh_api_lib.a
# General compiler flags
CFLAGS := -std=gnu99 -Wall -Werror -O
# Targets definition
MAIN_APP := sinkService
TARGET_APP := $(BUILDPREFIX)$(MAIN_APP)
# Add Api header (including logger files)
CFLAGS += -I$(MESH_LIB_FOLDER)api
# Add pthtread lib as needed by Mesh Lib
LDFLAGS += -pthread
# Add Reentrant flag as using pthread
CFLAGS += -D_REENTRANT
# Add systemd lib as needed for sd-bus
LDFLAGS += -lsystemd
# Add current directory for headers
CFLAGS += -I$(SOURCEPREFIX)
# Specific sources for this application
SOURCES := $(SOURCEPREFIX)main.c
SOURCES += $(SOURCEPREFIX)config.c
SOURCES += $(SOURCEPREFIX)data.c
SOURCES += $(SOURCEPREFIX)otap.c
OBJECTS := $(patsubst $(SOURCEPREFIX)%, \
$(BUILDPREFIX)%, \
$(SOURCES:.c=.o))
# Functions
# Also create the target directory if it does not exist
define COMPILE
echo " CC $(2)"
mkdir -p $(dir $(1))
$(CC) $(CFLAGS) -c -o $(1) $(2)
endef
define LINK
echo " Linking $(1)"
$(CC) $(CFLAGS) -o $(1) $(2) $(MESH_LIB) $(LDFLAGS)
endef
define CLEAN
echo " Cleaning up"
$(RM) -r $(BUILDPREFIX)
make -C $(MESH_LIB_FOLDER) clean
endef
# Target rules
# Use dependency files automatically generated by GCC.
# First collect all C source files
AUTODEPS := $(patsubst $(SOURCEPREFIX)%.c, $(BUILDPREFIX)%.d, $(SOURCES))
ifeq ($(V),1)
# "V=1" on command line, print commands.
else
# Default, do not print commands.
.SILENT:
endif
.PHONY: all
all: app
app: $(TARGET_APP)
.PHONY: clean
clean:
$(call CLEAN)
$(MESH_LIB_FOLDER):
$(error Please add the c-mesh-api library under c-mesh-api folder.\
It is needed to handle dualmcu protocol)
.PHONY: $(MESH_LIB)
$(MESH_LIB): $(MESH_LIB_FOLDER)
make -C $(MESH_LIB_FOLDER)
$(BUILDPREFIX)%.o: $(SOURCEPREFIX)%.c
$(call COMPILE,$@,$<)
$(BUILDPREFIX)$(MAIN_APP): $(OBJECTS) $(MESH_LIB)
$(call LINK,$@,$^)
---------------------------
What is wrong ?
Thanks ,Talel
The systemd issue is solved by installing the libsystemd in my native host, but I got another problem linking the lib with "ld" :
| /media/talel/data/menzu-zeus/menzu/tmp/work/aarch64-poky-linux/wirepas-sink-tool/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/ld: c-mesh-api/lib/build/mesh_api_lib.a(logger.o): Relocations in generic ELF (EM: 62)
| /media/talel/data/menzu-zeus/menzu/tmp/work/aarch64-poky-linux/wirepas-sink-tool/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/ld: c-mesh-api/lib/build/mesh_api_lib.a(logger.o): Relocations in generic ELF (EM: 62)
| /media/talel/data/menzu-zeus/menzu/tmp/work/aarch64-poky-linux/wirepas-sink-tool/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/ld: c-mesh-api/lib/build/mesh_api_lib.a: error adding symbols: file in wrong format
| collect2: error: ld returned 1 exit status
| makefile:102: recipe for target 'build/sinkService' failed
Here is the Makefile:
---------------------------
# Makefile for Wirepas Dbus Sink module
# Toolchain
CC ?= gcc
AS ?= as
LD ?= ld
AR ?= ar
# Paths, including trailing path separator
SOURCEPREFIX := source/
BUILDPREFIX := build/
# This example needs the mesh lib
MESH_LIB_FOLDER := c-mesh-api/lib/
MESH_LIB := $(MESH_LIB_FOLDER)build/mesh_api_lib.a
# General compiler flags
CFLAGS := -std=gnu99 -Wall -Werror -O
# Targets definition
MAIN_APP := sinkService
TARGET_APP := $(BUILDPREFIX)$(MAIN_APP)
# Add Api header (including logger files)
CFLAGS += -I$(MESH_LIB_FOLDER)api
# Add pthtread lib as needed by Mesh Lib
LDFLAGS += -pthread
# Add Reentrant flag as using pthread
CFLAGS += -D_REENTRANT
# Add systemd lib as needed for sd-bus
LDFLAGS += -lsystemd
# Add current directory for headers
CFLAGS += -I$(SOURCEPREFIX)
# Specific sources for this application
SOURCES := $(SOURCEPREFIX)main.c
SOURCES += $(SOURCEPREFIX)config.c
SOURCES += $(SOURCEPREFIX)data.c
SOURCES += $(SOURCEPREFIX)otap.c
OBJECTS := $(patsubst $(SOURCEPREFIX)%, \
$(BUILDPREFIX)%, \
$(SOURCES:.c=.o))
# Functions
# Also create the target directory if it does not exist
define COMPILE
echo " CC $(2)"
mkdir -p $(dir $(1))
$(CC) $(CFLAGS) -c -o $(1) $(2)
endef
define LINK
echo " Linking $(1)"
$(CC) $(CFLAGS) -o $(1) $(2) $(MESH_LIB) $(LDFLAGS)
endef
define CLEAN
echo " Cleaning up"
$(RM) -r $(BUILDPREFIX)
make -C $(MESH_LIB_FOLDER) clean
endef
# Target rules
# Use dependency files automatically generated by GCC.
# First collect all C source files
AUTODEPS := $(patsubst $(SOURCEPREFIX)%.c, $(BUILDPREFIX)%.d, $(SOURCES))
ifeq ($(V),1)
# "V=1" on command line, print commands.
else
# Default, do not print commands.
.SILENT:
endif
.PHONY: all
all: app
app: $(TARGET_APP)
.PHONY: clean
clean:
$(call CLEAN)
$(MESH_LIB_FOLDER):
$(error Please add the c-mesh-api library under c-mesh-api folder.\
It is needed to handle dualmcu protocol)
.PHONY: $(MESH_LIB)
$(MESH_LIB): $(MESH_LIB_FOLDER)
make -C $(MESH_LIB_FOLDER)
$(BUILDPREFIX)%.o: $(SOURCEPREFIX)%.c
$(call COMPILE,$@,$<)
$(BUILDPREFIX)$(MAIN_APP): $(OBJECTS) $(MESH_LIB)
$(call LINK,$@,$^)
---------------------------
What is wrong ?
Thanks ,Talel