Reputation: 423
I have written a package containing 3 files : foo.c, foo.h and README.TXT. Here is the recipe :
DESCRIPTION = "foo Drivers"
#To prevent the LICENSE field not set
LICENSE = "CLOSED"
PR = "r0"
SRC_URI = "file://foo.c \
file://foo.h \
file://README.txt"
FILES_${PN} += "${incdir}/foo.h"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/foo.c -o foo
}
do_install() {
install -m 0755 -d ${D}${bindir} ${D}${docdir}/foo ${D}${incdir}
install -m 0755 ${S}/foo ${D}${bindir}
install -m 0755 ${WORKDIR}/README.txt ${D}${docdir}/foo
install -m 0755 ${WORKDIR}/foo.h ${D}${incdir}
}
But when I do bitbake foo
I have this error :
WARNING: foo-0.0-r0 do_package: QA Issue: foo: Files/directories were installed but not shipped in any package:
/foo.h
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
foo: 1 installed and not shipped files. [installed-vs-shipped]
And because of this, in an another package depending on foo, when I add in the recipe : DEPENDS = "foo"
, I have this error :
fatal error: foo.h: No such file or directory
The error is from the line #include <foo.h>
.
Thank you for your help !
EDIT:
install -m 0755 ${WORKDIR}/foo.h ${D}${includedir}
Resolved the warning problem but I still have :
fatal error: foo.h: No such file or directory
When I want to compile a package depending on foo.h
EDIT2: I have changed the bblayer of my foo package to create a .so shared library, like so :
DESCRIPTION = "foo driver"
#To prevent the LICENSE field not set
LICENSE = "CLOSED"
PR = "r70"
SRC_URI = "file://foo.c \
file://foo.h \
file://README.txt"
CFLAGS_append =" -fPIC -g -c -Wall "
FILES_${PN} += "${libdir}/* ${libdir}/pkgconfig/*"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/foo.c -o foo
${CC} -shared -Wl,-soname,${WORKDIR}/libfoo.so.1 \
-o ${WORKDIR}/libfoo.so.1.0.1 foo -lc
}
do_install() {
install -m 0755 -d ${D}${bindir} ${D}${libdir} ${D}${docdir}/foo ${D}${includedir} ${D}${libdir}/pkgconfig
install -m 0755 ${S}/foo ${D}${bindir}
install -m 0755 ${WORKDIR}/README.txt ${D}${docdir}/foo
install -m 0755 ${WORKDIR}/foo.h ${D}${includedir}
install -m 0755 ${WORKDIR}/libfoo.so.1.0.1 ${D}${libdir}
ldconfig -n ${D}${libdir}
}
But in my Test package, even if I add #include <foo.h>
and DEPENDS = "pjproject gpio"
RDEPENDS_${PN} += "gpio"
I have error: undefined reference to
function coming from foo.h
. here is my test bblayer :
DESCRIPTION = "test"
LICENSE = "CLOSED"
PR = "r2"
SRC_URI = "file://main.c \
file://Makefile \
file://README.txt"
S = "${WORKDIR}/"
DEPENDS = "gpio"
RDEPENDS_${PN} += "gpio"
do_compile() {
cd ${S}
oe_runmake
}
do_install() {
install -m 0755 -d ${D}${bindir} ${D}${docdir}/test
install -m 0755 ${S}/test ${D}${bindir}
install -m 0755 ${WORKDIR}/README.txt ${D}${docdir}/test
}
And if I add -lfoo
in my Makefile, I have /bin/sh: 1: -lfoo: not found
.
Why ? thank you for your help !
Upvotes: 1
Views: 2167
Reputation: 14577
install -m 0755 ${WORKDIR}/foo.h ${D}${incdir}
this should be
install -m 0755 ${WORKDIR}/foo.h ${D}${includedir}
You can see in the QA warning message how your header got installed into /
instead of /usr/include/
.
You should also remove the FILES_{PN} line: it's wrong (because headers go into -dev package) and not needed as the right thing should be done by default.
Upvotes: 3