Discussion:
[yocto] Missing dependencies in recipe-sysroot
Georgi Georgiev
2018-12-04 07:53:27 UTC
Permalink
Hello,
As probably all yocto people know the sysrootfs policy changed in yocto rocko 2.4+. So I have the following issue:
I try to make a recipe for a shared library with makefile. The recipe is below (I don't claim it is complete. I simply cannot pass building stage):
#==================
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${THISDIR}/files/LICENSE;md5=5959e502cb44bafc53b2cc9400e3d4cd"
PR = "r0"

##### First try from my local repo and then we will use the big one
SRC_URI = "git:///home/w23698/projects/anybus/Generic;branch=anybus-lib-0.0.1"
SRCREV = "2fe4ce39a651d71f3f8de1c751dff2581de2c526"

S = "${WORKDIR}/git"

PACKAGES = "${PN} ${PN}-dev ${PN}-dbg"
#####The only dependency
RDEPENDS_${PN} = "libgpiod"
RDEPENDS_${PN}-dev = "libgpiod"
RDEPENDS_${PN}-dbg = "libgpiod"

do_compile() {
oe_runmake
}

do_install() {
install -d ${D}${libdir}
install -m 0644 ${PN}-m40 ${D}${libdir}
}

What was my surprise when it failed with:
ww.c:6:10: fatal error: gpiod.h: No such file or directory
| #include "gpiod.h"
| ^~~~~~~~~
| compilation terminated.
Then I noticed that the command line is:
arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/<full path>/recipe-sysroot -L/usr/lib -g -Wall -fpic .....
I looked in recipe-sysroot/usr/lib/ and found a minimal set of libraries and libgpiod was not there. Neither the header was there in include...

Any suggestions?

Cordially,
Georgi
Burton, Ross
2018-12-04 10:16:00 UTC
Permalink
We've already gone through this on SO but I'll copy/paste here.

On Tue, 4 Dec 2018 at 08:30, Georgi Georgiev
Post by Georgi Georgiev
#####The only dependency
RDEPENDS_${PN} = "libgpiod"
RDEPENDS_${PN}-dev = "libgpiod"
RDEPENDS_${PN}-dbg = "libgpiod"
DEPENDS = "libgpiod". RDEPENDS will build libgpiod at some point, but
it won't be in the sysroot for compilation. Before
recipe-specific-sysroots this would mean it *might* be present, now it
reliably won't.
Post by Georgi Georgiev
arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/<full path>/recipe-sysroot -L/usr/lib -g -Wall -fpic .....
The problem is the -L/usr/lib, which presumably should be where
libgpiod is. The makefile is broken, or possibly some tooling that
the makefile is calling. As you haven't shared the makefile we can't
help further.

Ross
--
Georgi Georgiev
2018-12-04 14:02:17 UTC
Permalink
Thank you Ross,
Compilation issues are gone...Only one DEPENDS appeared to be enough :-). Thank you again
But can give me a hand to the following because now I have QA issues during my "corrupted" makefile. Is there any way to pass this --sysroot=/<full path>/recipe-sysroot before -L/usr/lib. Eg somehow the whole path to be like -L/<full path>/recipe-sysroot/usr/lib in my makefile. gcc actually follows --sysroot and /usr/include is to target sysroot...but one annoying warning appear and now this is my last issue.
cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
QA stage (do_package_qa) does not pass.
Here is my "corrupted" makefile:

# we will use env from poky CC := arm-linux-gnueabihf-gcc
CFLAGS := -g -Wall -fpic
RM = rm -f $(DEPDIR)/*.d $(OBJDIR)/*.o *~ $(OUTPUT)
DEPDIR := dep
OBJDIR := obj
OUTPUT := libanybus-m40.so.0.0.1

LOCAL_SRC_DIRS := .
LOCAL_SRC_DIRS += abcc_adapt
LOCAL_SRC_DIRS += abcc_drv/src
LOCAL_SRC_DIRS += abcc_drv/src/par
LOCAL_SRC_DIRS += abcc_drv/src/par30
LOCAL_SRC_DIRS += abcc_drv/src/serial
LOCAL_SRC_DIRS += abcc_drv/src/spi

LOCAL_INC_DIRS := .
LOCAL_INC_DIRS += abcc_abp
LOCAL_INC_DIRS += abcc_adapt
LOCAL_INC_DIRS += abcc_drv/inc
LOCAL_INC_DIRS += abcc_drv/src
LOCAL_INC_DIRS += abcc_drv/src/par
LOCAL_INC_DIRS += abcc_drv/src/par30
LOCAL_INC_DIRS += abcc_drv/src/serial
LOCAL_INC_DIRS += abcc_drv/src/spi
LOCAL_INC_DIRS += /usr/include

SRC := $(foreach sdir,$(LOCAL_SRC_DIRS),$(wildcard $(sdir)/*.c))
INC := $(foreach idir,$(LOCAL_INC_DIRS),-I$(idir))
LIB := -L/usr/lib
LDFLAGS := -lgpiod -shared -fPIC -Wl,-soname,libanybus-m40.so.0
OBJ := $(addprefix $(OBJDIR)/,$(notdir $(SRC:.c=.o)))
DEP := $(addprefix $(DEPDIR)/,$(notdir $(OBJ:.o=.d)))

VPATH = $(LOCAL_SRC_DIRS)

ifneq "$(findstring clean,$(MAKECMDGOALS))" "clean"
-include $(DEP)
endif

.PHONY: all clean dirtree
.DEFAULT_GOAL := all

all: $(OUTPUT)

$(OUTPUT): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $(LIB) $^

$(DEPDIR)/%.d: %.c
$(CC) $(LIB) -MM -MF $@ -MP -MT "$(OBJDIR)/$*.o $@" $(CFLAGS) $(INC) $<


$(OBJDIR)/%.o: %.c
$(CC) $(LIB) $(CFLAGS) $(INC) -c -o $@ $<

$(OBJ) $(DEP): | dirtree

dirtree:
mkdir -p $(DEPDIR) $(OBJDIR)

clean:
$(RM)

Cordially,
Georgi
-----Original Message-----
From: Burton, Ross [mailto:***@intel.com]
Sent: Tuesday, December 04, 2018 12:16 PM
To: Georgi Georgiev <***@woodward.com>
Cc: Yocto-mailing-list <***@yoctoproject.org>
Subject: [EXTERNAL] Re: [yocto] Missing dependencies in recipe-sysroot

We've already gone through this on SO but I'll copy/paste here.
Post by Georgi Georgiev
#####The only dependency
RDEPENDS_${PN} = "libgpiod"
RDEPENDS_${PN}-dev = "libgpiod"
RDEPENDS_${PN}-dbg = "libgpiod"
DEPENDS = "libgpiod". RDEPENDS will build libgpiod at some point, but it won't be in the sysroot for compilation. Before recipe-specific-sysroots this would mean it *might* be present, now it reliably won't.
Post by Georgi Georgiev
arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/<full path>/recipe-sysroot -L/usr/lib -g -Wall -fpic .....
The problem is the -L/usr/lib, which presumably should be where libgpiod is. The makefile is broken, or possibly some tooling that the makefile is calling. As you haven't shared the makefile we can't help further.

Ross
--
Burton, Ross
2018-12-04 14:12:54 UTC
Permalink
On Tue, 4 Dec 2018 at 14:02, Georgi Georgiev
Post by Georgi Georgiev
LIB := -L/usr/lib
^ don't do that. That's not where the libraries are.

Ross
--
Georgi Georgiev
2018-12-04 15:13:59 UTC
Permalink
OK but. I can use SDKTARGETSYSROOT in my makefile but then it will fail in yocto...So I can't have one makefile for yocto and command line build...I found one tread for similar issue and I will take a look in poky/meta/conf/bitbake.conf tomorrow.

Georgi

-----Original Message-----
From: Burton, Ross [mailto:***@intel.com]
Sent: Tuesday, December 04, 2018 4:13 PM
To: Georgi Georgiev <***@woodward.com>
Cc: Yocto-mailing-list <***@yoctoproject.org>
Subject: Re: [EXTERNAL] Re: [yocto] Missing dependencies in recipe-sysroot
Post by Georgi Georgiev
LIB := -L/usr/lib
^ don't do that. That's not where the libraries are.

Ross
--
Burton, Ross
2018-12-04 15:43:55 UTC
Permalink
No, you just need to write your makefile correctly. libgpiod has a
pkg-config file, so instead of hard-coding paths like /usr/lib
(because you don't know that's where it is installed) just use
pkg-config to get the flag:

gcc $(pkg-config --cflags --libs libgpiod) ...

Ross
On Tue, 4 Dec 2018 at 15:14, Georgi Georgiev
Post by Georgi Georgiev
OK but. I can use SDKTARGETSYSROOT in my makefile but then it will fail in yocto...So I can't have one makefile for yocto and command line build...I found one tread for similar issue and I will take a look in poky/meta/conf/bitbake.conf tomorrow.
Georgi
-----Original Message-----
Sent: Tuesday, December 04, 2018 4:13 PM
Subject: Re: [EXTERNAL] Re: [yocto] Missing dependencies in recipe-sysroot
Post by Georgi Georgiev
LIB := -L/usr/lib
^ don't do that. That's not where the libraries are.
Ross
--

Loading...