Yocto include cmake compilation with custom steps - cmake

I'm trying to add elibinie package into my custom recipe layer in yocto !
The step to install this package are :
* git clone https://github.com/pcercuei/libini.git
* cd libini
* mkdir build && cd build && cmake ../ && make && sudo make install
Normally yocto take care to install ccmake with do install but with my recipe "libinit.bb", i get compilation error.
libinit.bb :
DESCRIPTION = ""
SECTION = "libini"
DEPENDS = ""
LICENSE = "CLOSED"
SRC_URI = "git://github.com/pcercuei/libini.git;protocol=https"
SRCREV = "e22154361dfc63778a1ca4f153f085c5236ed8f7"
S = "${WORKDIR}/git"
inherit cmake
do_install() {
install -d ${D}/home/root/
install -m 0755 libini ${D}/home/root/
}
error compilation :
linux/libini/1.0-r0/temp/run.do_install.42454' failed with exit code 1:
install: cannot stat 'libini': No such file or directory
I think there is more problem than just cmake, maybe the problem come from folder that i try to install.
Also how should creat build folder in git source and let cmake working !

Related

Yocto recipe to install binaries generated from cmake

I am new to Yocto and cmake. After looking and searching on internet I was able to make my own recipe and was able to successfully compile the code using cmake from Yocto recipe.
But the binary compiled and generated is in the build folder where the code source files reside. How do I copy over the binaries from the build folder to the custom file system path when the image is generated using Yocto.
My .bb file currently looks like this:
#
# This file is the pscode recipe.
#
SUMMARY = "Simple test application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://src/* \
file://include/* \
file://CMakeLists.txt\
"
S = "${WORKDIR}"
do_configure() {
cmake ../
}
inherit pkgconfig cmake
do_install() {
install -d ${D}/home/first
cp -r ${WORKDIR} ${D}/home/first
#install -m 0755 ${S} ${D}/home/first
}
FILES_${PN} += "/home/first"
This runs into error
cp: cannot copy a directory <path-to-the-test-folder-in-temp> into itself, <path-to-the-test-folder-in-temp/image/home/first>
Can I someone please guide me. Thank you in advance.
Like the comments suggested:
SUMMARY = "Simple test application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://src/* \
file://include/* \
file://CMakeLists.txt \
"
S = "${WORKDIR}"
inherit pkgconfig cmake
If the CMakeLists.txt uses the install command then bitbake will do the install for you and you won't need to define you own do_install. see cmake-documentation-install for details. Here the example for binaries:
install(TARGETS <your cmake target> DESTINATION bin)
From cmake install documentation:
If a full path (with a leading slash or drive letter) is given it is
used directly. If a relative path is given it is interpreted relative
to the value of the CMAKE_INSTALL_PREFIX variable.

Create default files for conan without install

I'm creating a docker image as a build environment where I can mount a project and build it. For build I use cmake and conan. The dockerfile of this image:
FROM alpine:3.9
RUN ["apk", "add", "--no-cache", "gcc", "g++", "make", "cmake", "python3", "python3-dev", "linux-headers", "musl-dev"]
RUN ["pip3", "install", "--upgrade", "pip"]
RUN ["pip3", "install", "conan"]
WORKDIR /project
Files like
~/.conan/profiles/default
are created after I call
conan install ..
so that these files are created in the container and not in the image. The default behavior of conan is to set
compiler.libcxx=libstdc++
I'd like to run something like
RUN ["sed", "-i", "s/compiler.libcxx=libstdc++/compiler.libcxx=libstdc++11/", "~/.conan/profiles/default"]
to change the libcxx value but this file does not exist at this point. The only way I found to create the default profile by conan would be to install something.
Currently I'm running this container with
docker run --rm -v $(dirname $(realpath $0))/project:/project build-environment /bin/sh -c "\
rm -rf build && \
mkdir build && \
cd build && \
conan install -s compiler.libcxx=libstdc++11 .. --build missing && \
cmake .. && \
cmake --build . ; \
chown -R $(id -u):$(id -u) /project/build \
"
but I need to remove -s compiler.libcxx=libstdc++11 as it should be dependent on the image and not fixed by the build script.
Is there a way to initialize conan inside the image and edit the configuration without installing something? Currently I'm planning to write the whole configuration by myself but that seems a little too much as I want to use the default configuration and change only one line.
You can also create an image from a running container. Try installing conan in running container and then create an image of it. As it is being installed in running container it will have all dependencies only for it. To create that image you can follow this link
https://docs.docker.com/engine/reference/commandline/commit/

RPI Native Build Qt 5.10.1: config test architecture failure

Hi I am trying to build QT 5.10.1 with this guide. I am getting this error;
Command line: -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option
CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix
/usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip
qtscript -nomake examples -no-use-gold-linker -make libs -v
executing config test architecture
+ cd /home/pi/qt5build/config.tests/arch &&
/home/pi/qt5build/qtbase/bin/qmake "CONFIG -= qt debug_and_release
app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch"
"QMAKE_CFLAGS += --sysroot=/opt/qt5pi/sysroot" "QMAKE_CXXFLAGS += --
sysroot=/opt/qt5pi/sysroot" "QMAKE_LFLAGS += --sysroot=/opt/qt5pi/sysroot" -
early "CONFIG += cross_compile" /home/pi/qt-everywhere-src-
5.10.1/qtbase/config.tests/arch
+ cd /home/pi/qt5build/config.tests/arch && MAKEFLAGS= /usr/bin/make clean
&& MAKEFLAGS= /usr/bin/make
> rm -f arch.o
> rm -f *~ core *.core
> arm-linux-gnueabihf-g++ -c -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-
neon-
fp-armv8 -mfloat-abi=hard --sysroot=/opt/qt5pi/sysroot -O2 -w -fPIC -
I/home/pi/qt-everywhere-src-5.10.1/qtbase/config.tests/arch -I. -
I/home/pi/qt-everywhere-src-5.10.1/qtbase/mkspecs/devices/linux-rasp-
pi3-vc4-g++ -o arch.o /home/pi/qt-everywhere-src-
5.10.1/qtbase/config.tests/arch/arch.cpp
> /home/pi/qt-everywhere-src-5.10.1/qtbase/config.tests/arch/arch.cpp:43:19:
fatal error: stdio.h: No such file or directory
> #include <stdio.h>
> ^
> compilation terminated.
> Makefile:179: recipe for target 'arch.o' failed
> make: *** [arch.o] Error 1
I checked the include file in the /usr location it is there. If I add the file arch.cpp location then it needs another file. How can I fix this?
Thanks for help.
fatal error: stdio.h: No such file or directory
This suggests you are missing build dependencies on your host machine (the machine on which you are running configure), most likely libc
I'm not sure what package manager you have, but with apt you can install this with:
sudo apt install libc6-dev
Failing that, you also might like to try:
sudo apt install build-essential
which installs various compilation tools/libraries.

How to insert OV5640 camera driver as module in yocto

I am trying to use the OV5640 camera driver as a module in yocto. So I took the .c code and made a makefile (based on the example hello-mod)
obj-m += OV5640.o
SRC := $(shell pwd)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) clean
I also made a recipe in yocto
DESCRIPTION = "..."
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "\
file:// ${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \
"
inherit module
SRCREV = "${AUTOREV}"
BPV = "0.0.0"
PV = "${BPV}+git${SRCREV}"
SRC_URI = "git://git/my-repo;protocol=ssh;user=git;branch=master \
"
S = "${WORKDIR}/git"
In the git repo I have the .c code of the camera and the Makefile.
But when I try to build, it fails on do_compile and says:
fatal error: v4l2-int-device.h: No such file or directory
When I search on the file in the 'tmp' folder of yocto I find one in:
tmp/work-shared/myboard/kernel-source/drivers/media/platform/mxc/capture/v4l2-int-device.h
The question is, How can I modify the recipe to be able to build the module without changing the source code or the makefile?
Note:
I also tried to add snippet below to the recipe but this gave no succes.
CFLAGS_prepend = " -I${STAGING_KERNEL_DIR}/drivers/media/platform/mxc/capture "
You need to modify your Makefile and add:
ccflags-y += -I$(KERNEL_SRC)/drivers/media/platform/mxc/capture/
You can also try to compile it out of the tree, you need to set the variable KERNEL_SRC, source your environment, and compile it.

Can I remove directory after $git clone and $make install

I wrote myself a litte script to install opencv under ubuntu14.04. Can I remove the directory 3party after the make install sorted the lib into system directories or are there dependencies? (Remove not only the MYBUILD but the complete 3party)
echo "\nInstall OpenCV?...<any key>\n"
read inp1; # $inp1
mkdir 3party;
cd 3party;
git clone https://github.com/Itseez/opencv.git
cd opencv;
mkdir MYBUILD;
cd MYBUILD;
#sudo mkdir -p /usr/local/lib/opencv;
cmake -L -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local .. ;
echo"check if path is ok?...<any key> or abort";
read inp1; # $inp1
make;
#sudo mkdir -p /usr/local/lib/opencv;
make install;
cd ../../..;
chmod -R 777 3party;
echo "\nDone.\nPlease exit...<any key>";
EDIT: I did tag it cmake because the configuration step is performed with this build tool. Also the tutorial on the OpenCV website stated it. Please correct me if wrong.
Building OpenCV from Source Using CMake, Using the Command Line
Normally, after installation of any package its source and binary directories can be safetly removed. OpenCV follows this convention too.