sd-bus.h not found even with DEPENDS += "systemd"


Bel Hadj Salem Talel <bhstalel@...>
 

Hi Community,

I'm trying to make a recipe for source files with a Makefile , files are under : https://github.com/wirepas/gateway/tree/master/sink_service

I can't add the recipe directly from the URL, so I cloned the repo and zipped only the sink_service file.

When I added the zip file with devtool it added DEPEND = "systemd" in the recipe file. But when compiling :
fatal error: systemd/sd-bus.h: No such file or directory
The Makefile just needs "make" and it worked on my native host. Here is the recipe:
LICENSE = "Unknown"
LIC_FILES_CHKSUM = "file://c-mesh-api/LICENSE;md5=b8b4f77337154d1f64ebe68dcd93fab6"
SRC_URI = "file:///media/talel/data/multigate/multigate/meta-wirepas/recipes-wirepas/wirepas-sink-tool/files/sink_service.zip"
DEPENDS = "systemd"
do_configure () {
# Specify any needed configure commands here
:
}

do_compile () {
# You will almost certainly need to add additional arguments here
oe_runmake
}

do_install () {
# NOTE: unable to determine what to put here - there is a Makefile but no
# target named "install", so you will need to define this yourself
:
}

The only problem is in do_compile , I need to fix it and then I can manage the install part.
How can I specify the libsystemd in BUILD time , do I need EXTRA_OEMAKE ?

Thanks, Talel



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


Bel Hadj Salem Talel <bhstalel@...>
 

Hi,

A response came only to me :

Hey Bel,
 
Please remove the libsystemd from your host. It will cause host contamination.
 
You need to tell in your makefile where make can find include path and lib path
 
Normally it should work
 
Include: -I${STAging_incdir}
-L for ld path
 
 
Cheers
So I added

EXTRA_OEMAKE += "-I${STAGING_INCDIR}
to fix the systemd include error.

But I still get the error of :

 /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

I don't know what is the problem.
Help me on this please.

Thanks for your support.



Josef Holzmayr
 

Without digging into the details, it sounds very very much like the most of your problems are caused by handcrafting a Makefile which is not cross compile aware and probably has multiple other issues. Therefore I strongly suggest to use a build system like autotools, cmake or meson. You can find an introduction to a cmake-based setup here: https://youtu.be/NmPta5w6P70

Greetz

Am So., 27. Sept. 2020 um 14:42 Uhr schrieb Bel Hadj Salem Talel <bhstalel@...>:

Hi,

A response came only to me :

Hey Bel,
 
Please remove the libsystemd from your host. It will cause host contamination.
 
You need to tell in your makefile where make can find include path and lib path
 
Normally it should work
 
Include: -I${STAging_incdir}
-L for ld path
 
 
Cheers
So I added

EXTRA_OEMAKE += "-I${STAGING_INCDIR}
to fix the systemd include error.

But I still get the error of :

 /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

I don't know what is the problem.
Help me on this please.

Thanks for your support.