Build custom Yocto recipe with meson and ninja - yocto

I'm trying to write a custom recipe for a library from github (Aravis). The build/install steps are done using meson and ninja.
$ meson build
$ cd build
$ ninja
$ ninja install
Before writing/adding the recipe, I've added meson, ninja and dependencies in my custom layer.conf. Then, on system, I've cloned the library, compiled it and run some test. Everything works fine, so I'm sure meson, ninja and all dependencies are in place (at system level).
Now I've wrote the recipe
SUMMARY = "Aravis, Your industrial vision library"
LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/LGPL-2.1-only;md5=1a6d268fd218675ffea8be556788b780"
inherit systemd
SRC_URI = "https://github.com/AravisProject/aravis/archive/refs/tags/0.8.22.tar.gz"
SRC_URI[md5sum] = "8d24f794b1c5160f21c2b0d77764c86d"
DEPENDS=" \
gstreamer1.0 \
gstreamer1.0-plugins-base \
libxml2 \
glib-2.0 \
glib-2.0-native \
zlib \
libusb1 \
gtk-doc \
gobject-introspection \
intltool-native \
meson \
"
S = "${WORKDIR}/aravis-0.8.22"
do_configure() {
( cd ${S}
meson build )
}
do_build() {
( cd ${S}/build
ninja )
}
do_install () {
( cd ${S}/build
ninja install )
}
The do_configure() step fails with a meson: not found error. I don't know about ninja yet (didn't reach the do_build()), but it will probably fail, too.
How to have meson and ninja tools available at compile level?
As a blind test, I tried rebuilding the toolchain (bitbake meta-toolchain-qt5), hoping those tools will be added for the next image build, but with no luck.
EDIT
I've also noticed that meson and ninja are already available in my sdk (the one installed on host for cross-compilation after build with mentioned command bitbake meta-toolchain-qt5).
mix#SWDEV1:/opt/fsl-imx-xwayland/5.10-hardknott/sysroots/x86_64-pokysdk-linux$ find . -name ninja
./usr/bin/ninja
mix#SWDEV1:/opt/fsl-imx-xwayland/5.10-hardknott/sysroots/x86_64-pokysdk-linux$ find . -name meson
./usr/share/meson
./usr/bin/meson
The tools are available. I just need to understand how to use them.

Found the problem.
Another test I did was adding inherit meson and removing the custom tasks, but without luck.
Testing it a little more, I discovered the the problem was the recipe name, that was aravis_%.bb. Since I didn't define a recipe version, the resulting build path was tmp/work/cortexa53-crypto-poky-linux/aravis/%_r0/, and it looks like meson doesn't like the character %.
So I've edited my recipe so that the version is defined
SUMMARY = "Aravis, Your industrial vision library"
LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/LGPL-2.1-only;md5=1a6d268fd218675ffea8be556788b780"
PV = "0.8.22"
SRC_URI = "https://github.com/AravisProject/aravis/archive/refs/tags/${PV}.tar.gz"
SRC_URI[md5sum] = "8d24f794b1c5160f21c2b0d77764c86d"
DEPENDS=" \
gstreamer1.0 \
gstreamer1.0-plugins-base \
libxml2 \
glib-2.0 \
glib-2.0-native \
zlib \
libusb1 \
gtk-doc \
gobject-introspection \
intltool-native \
"
S = "${WORKDIR}/aravis-${PV}"
inherit meson
Now the library will be compiled and installed.

Related

Install CANopen package in yocto

I have tried installing CANopen in yocto using below command. But the CANOpen is not getting installed.
bitbake canopensocket_git
In local.conf file I had added
CORE_IMAGE_EXTRA_INSTALL += " canopensocket_git "
How I can install canopen package?
Any input is also considered.
First of all, that's a syntax error canopensocket_git.
The recipe name ${PN} is canopensocket and every thing after the_ is the version number ${PV}.
So, you need to only specify the recipe name. Or if you have different versions you can specify one by:
PREFERRED_VERSION_canopensocket = "version_here"
That being said, I found a recipe for canopensocket in here.
But if fails and it is not updated with latest github commit.
I did some modifications on it, here is my recipe:
SUMMARY = "Linux CANOpen tools"
DESCRIPTION = "Linux CANOpen Protocol Stack Tools"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://gpl-2.0.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRC_URI = "git://github.com/CANopenNode/CANopenSocket.git"
SRCREV = "ec9735165502e08b5d2e84d641833709b6faeb96"
S = "${WORKDIR}/git"
do_compile_prepend() {
cd ${S}
git submodule init
git submodule update
}
do_compile() {
cd ${S}/cocomm
make
cd ${S}/canopencgi
make
}
do_install(){
install -d ${D}${bindir}
install -m 0755 ${S}/cocomm/cocomm ${D}${bindir}
install -m 0755 ${S}/canopencgi/canopen.cgi ${D}${bindir}
}
FILES_${PN} += "${bindir}/*"
I modified do_compile, do_install and added the packaging of FILES.
And I set SRCREV to the latest v4 tag commit instead of AUTOREV.
I do not know what this recipe does, but I compiled it and the build was okay for me on a zeus build.
The build produced two binaries: cocomm and canopen.cgi .
No if you want to install it to your image, add this to you cutom image recipe:
IMAGE_INSTALL_append = " canopensocket"

Trying to make automatic compilation of an Unity Engine project on Ubuntu

I'm working on a project an Unity Engine project which is in version 2017.4.36f1. I would like to automatise the build of this project on the Gitlab with the online runners.
So I made a .gitlab-ci.yml to make a custom pipeline. In this pipeline I use the image ubuntu:16.04.
I download Unity using wget -nv https://beta.unity3d.com/download/c663def8414c/UnitySetup-2017.4.36f1
I install it with echo y | xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' ./UnitySetup --unattended --install-location=Unity --verbose --download-location=/tmp/unity --components=Unity, Windows
I activate the licence for this computer and then I build for Windows 64 with the command line
${UNITY_EXECUTABLE:-xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' $HOME/Unity/Editor/Unity} \
-projectPath $(pwd)/ClientUnity/MK_Unity3D \
-quit \
-batchmode \
-buildTarget StandaloneWindows64 \
-customBuildTarget StandaloneWindows64 \
-customBuildPath BuildStandaloneWindows64 \
-executeMethod BuildCommand.PerformBuild \
-logFile /dev/stdout
There is no error during the build but at the end It cannot found the Windows standalone Package and so it stops.
Here is the message given at the end of the build :
Initializing Unity.PackageManager (PackageManager) v2017.4.36 for Unity v2017.4.36f1
Registering platform support modules:
Registered platform support modules in: 0.1674048s.
Native extension for WindowsStandalone target not found
Native extension for LinuxStandalone target not found

Shared libraries cannot be found when building application in Yocto

I tried to compile my application with cmake in my Yocto project. My application depends on some static and dynamic libraries. And I added the dependencies in my recipe. I confirmed that all .so and .a have had been installed into recipe-sysroot/usr/lib during building. But some errors still occurs, like,
ld: cannot find -lparson
ld: cannot find -luamqp
And I also observed some wired messages like,
-L/yocto/build_test/tmp/work/armv7at2hf-neon-fslc-linux-gnueabi/my-app/1.0-r0/git/lib
but there is no git/lib
How can I change the link directory to /usr/lib
DEPENDS = "\
azure-iot-sdk-c \
openssl \
zlib \
curl \
boost \
parson \
gtest \
"
S = "${WORKDIR}/git"
B = "${WORKDIR}/build"

Create RPM from pre-built binary with no source code

I'm trying to create an rpm package for Hashicorp Vault. I can download the Vault binary as a zip file from the website, but clueless about how to get that binary packed as an rpm. I tried fpm but I guess I can't use that for packaging pre-built binaries.
I know a directory tree has to be setup to create an rpm, but I don't know what to put in the files inside it, as all I have is a vault binary zipped. No sure about what to put in SPEC file either
I could create a deb for the same using dhmake followed by debuild, but not sure how to go about creating an rpm.
Any help? :sad_panda:
FPM was the solution. Just that I couldn't figure out the right way to use it. So this is what I used:
Downloaded the zip file, extracted the binary file ($filename), then
mkdir -p /install/vault; cp $filename /install/vault/
fpm -s dir \
-t rpm \
--name vault \
--version 0.6.4 \
--url https://www.vaultproject.io \
-C /install/vault \
.```
FPM is awesome!
It actually does not matter if you package binaries or compile it from source. Just learn how to package SW as RPM. Here is bunch of links to study: https://fedorahosted.org/copr/wiki/UserDocs#HowcanIpackagesoftwareasRPM

command-line library build fails with linker error

I am getting a library not found error building GraphViz current release (June 7 2012) with Xcode 4.3 using a script. I may have made mistakes updating build scripts from other people's successful recipes for the new location of Xcode4.3 and the developer tools in the Applications folder.
ld: library not found for -lcrt1.10.6.o
(doing this from memory so exact number on the CRT lib may be wrong)
Am also a little lost also how I would incorporate this into an Xcode build in the IDE. I am a very experienced programmer but having trouble finding my way around Xcode 4 at times. (Decades of Visual Studio et al).
I have copied the instructions from this earlier question and adapted
#!/bin/sh
# For iPhoneOS, see http://clang.llvm.org/ for options
export DEV_iOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
# was /Developer/Platforms/iPhoneOS.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneOS5.1.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/clang
export CXX=${COMPILER_iOS}/clang++
export LDFLAGS="-arch armv7 -pipe -Os -gdwarf-2 -mthumb -isysroot ${SDK_iOS}"
export CFLAGS="${LDFLAGS}"
export OBJCFLAGS="${LDFLAGS}"
export CXXFLAGS="${LDFLAGS} -fvisibility-inlines-hidden"
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/clang
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP="${COMPILER_iOS}/clang++"
export OBJC=${COMPILER_iOS}/clang
export RANLIB=${COMPILER_iOS}/ranlib
./configure \
--build=arm-apple-darwin11 \
--host=arm-apple-darwin11 \
--disable-dependency-tracking \
--enable-shared=no \
--enable-static=yes \
--enable-ltdl=no \
--enable-swig=no \
--enable-tcl=no \
--srcdir=${GVROOT} \
--with-codegens=no \
--with-cgraph=no \
--with-graph=yes \
--with-expat=no \
--with-fontconfig=no \
--with-freetype2=no \
--with-ipsepcola=yes \
--with-libgd=no \
--with-quartz=yes \
--with-visio=yes \
--with-x=no
The compiler normally uses crt1.o combined with crt[i/n].o and crt[begin/end].o to support the constructors and destructors (functions called before and after main and exit).
This error could be caused by this missing library file for the specific deployment target.
First, do some investigation, like:
list all your deployment targets:
ls -la /Developer/SDKs
and find which crt1 libraries do you have for which environment
find /Developer/SDKs -name crt1\*
You could see something like:
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.o
So as you can see, crt1.10.6.o is missing for MacOSX10.5.
Solution 1:
You can solve that by creating the link to the missing file pointed to the other environment, or you could change your deployment target.
E.g.
ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o /Developer/SDKs/MacOSX10.5.sdk/usr/lib/
Also this could be caused, that you have different gcc installed in your system. See:
which gcc;
xcrun -find gcc;
brew list | grep gcc; brew list gcc47
Solution 2
So when you're compiling using make, you can actually specify the right compiler by CC variable. E.g.
CC=/path/to/gcc-3.4 make
Solution 3
What you can also try is specifying the right target deployment environment variable for gcc, by executing the following lines:
export MACOSX_DEPLOYMENT_TARGET=10.5
export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include
export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib
If this works, then you can add above lines to your shell profile (~/.profile) to make the change permanent.
How to test
Create the example conftest.c file with the following code:
#ifdef __GNUC__
yes;
#endif
And try to compile it via:
gcc conftest.c
cc conftest.c
cc conftest.cc conftest.c
Troubleshooting
To see which exactly what file is missing, try to debug it using dtruss, e.g.:
sudo dtruss -f gcc conftest.c 2>/dev/stdout | grep crt
You should see something like:
12426/0xb4e3b: stat64("/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/crt1.10.6.o\0", 0x7FFF5FBFE780, 0xB) = -1 Err#2
So once you found the missing file, then you can follow by the first solution by linking the missing file from existing location (e.g. locate crt1.10.6.o). If you will have other missing symbols, then try another file (check the architecture before by: file `locate crt1.10.6.o`).
E.g.
sudo ln -s /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/crt1.10.6.o /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/crt1.10.6.o
sudo ln -s /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/crt1.10.6.o /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64/crt1.10.6.o
Related
Error in xcode project: ld: library not found for -lcrt1.10.6.o
If I remember correctly this is what fixed the library not found problem.
CFLAGS="$(OTHER_CFLAGS) -miphoneos-version-min=5.0"
LDFLAGS="$(OTHER_LDFLAGS) --miphoneos-version-min=5.0"
To link this to Xcode, under Build Settings then Header and Library search paths you need to add the paths to the built versions of the library and the header.
You can add the build script as part of your Xcode project, but I haven't had success with this, plus you should only need to build it once per version, so putting the time into anything other than a build script doesn't have much return.
If you decide to put the script in your project anyway (good luck!), then go to the build phases tab, add a build phase of type "Run Script" and paste your script there.