Adding .so and symlink to .so in Yocto - shared-libraries

I want to have multiple versions of library mylib and symlink that points to latest one. So, there would be latest library in /usr/lib/mylib/mylib.so.0.5 and symlink /usr/lib/mylib/mylib.so -> /usr/lib/mylib/mylib.so.0.5.
My recipe can currently work without adding symlink
My Yocto recipe is working nicely when I remove following line:
lnr ${D}${libdir}/mylibrary/mylib.so.${MY_LIB_VER} ${D}${libdir}/mylibrary/mylib.so
FILES_{PN}-dev += "${D}${libdir}/mylib/mylib.so.${MYLIB_VER}"
FILES_{PN}-dev += "${D}${libdir}/mylib/mylib.so"
Error that prevents me from building:
QA Issue: non -dev/-dbg/nativesdk- package contains symlink .so

So instead of adding .so files to FILES_{PN}-dev
FILES_{PN}-dev += "${D}${libdir}/mylib/mylib.so.${MYLIB_VER}"
FILES_{PN}-dev += "${D}${libdir}/mylib/mylib.so"
I've added it to FILES_SOLIBSDEV
FILES_SOLIBSDEV += "${D}${libdir}/mylib/mylib.so.${MYLIB_VER}"
FILES_SOLIBSDEV += "${D}${libdir}/mylib/mylib.so"
and now everything is building and package on which this package depends on sees it as available. I haven't fully built that other package, but packagesare available in build/tmp/sysroots-components folder.

Related

How to add header file to /usr/include in Yocto

I am working with Linux built with Yocto. I would like to add to the image my app to /bin and some header file to /usr/include. I have no problem with adding the app to /bin, but I am not able to add the header file to my rootfs. The .h file is added to a proper package, but it is not copied to rootfs.
Here is my recipe:
bindir = "${localdir}/bin"
incldir = "${localdir}/usr/include"
FILESEXTRAPATHS_prepend := "${THISDIR}/files/:"
SRC_URI = "file://My_app_dir/* \
\
"
S = "${WORKDIR}"
FILES_${PN} += "${incldir}/*"
do_compile() {
cd My_app_dir/src
make
}
do_install() {
install -d ${D}${bindir}
cp "${S}/My_app_dir/src/my_app" "${D}${bindir}/my_app"
install -d ${D}${incldir}
cp "${S}/My_app_dir/some_lib.h" "${D}${incldir}/some_lib.h"
}
After building the image, the include file exists in /build/tmp/work/<machine>/<my_app>/image/usr/include.
Do you have any idea why I cannot add .h file to /usr/include in rootfs? Thank you in advance for any help.
The header files (among other files like pkgconfig and shared library symlinks) are not added to the main package (say foo), but to the development package (e.g. foo-dev). This is called package split and you can learn more in the Package Splitting of the official documentation. The development packages (and BTW also the debug foo-dbg) are not installed by default.
But please be aware that adding the development package may pull other dependencies (because of various runtime dependencies) and files (there are other files in the development package).
Please note that your line FILES_${PN} += "${incldir}/*" has no effect, as the files in $includedir (i.e. FILES_${PN}-dev) are split before the FILES_${PN} are processed. The order is defined in the variable PACKAGES (check the official documentation).
BTW, there are minor things in the recipe which you can update (unrelated to your question though):
You can use location of standard system paths in the respective variables bindir, includedir etc.
install is preferred over the cp in do_install.
The line FILESEXTRAPATHS_prepend := "${THISDIR}/files/:" is needed only in bbappends. The files directory inside the recipe's directory is in the standard search path of files (among other paths like ${PN} etc.).

OpenCV build Error: libwebp.so not found

I have two Arch Linux machines on one I can compile my code but on my new one I get the following errors:
:-1: warning: libwebp.so.5, needed by /usr/local/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link)
/usr/local/lib/libopencv_imgcodecs.so:-1: error: undefined reference to `WebPEncodeBGRA'
/usr/local/lib/libopencv_imgcodecs.so:-1: error: undefined reference to `WebPDecodeBGRAInto'
/usr/local/lib/libopencv_imgcodecs.so:-1: error: undefined reference to `WebPEncodeLosslessBGR'
/usr/local/lib/libopencv_imgcodecs.so:-1: error: undefined reference to `WebPDecodeBGRInto'
/usr/local/lib/libopencv_imgcodecs.so:-1: error: undefined reference to `WebPEncodeLosslessBGRA'
/usr/local/lib/libopencv_imgcodecs.so:-1: error: undefined reference to `WebPGetFeaturesInternal'
/usr/local/lib/libopencv_imgcodecs.so:-1: error: undefined reference to `WebPEncodeBGR'
:-1: error: collect2: error: ld returned 1 exit status
My .pro file looks like this:
#-------------------------------------------------
#
# Project created by QtCreator 2015-11-15T16:30:56
#
#-------------------------------------------------
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ColonyCounter
TEMPLATE = app
CONFIG += c++11
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc
SOURCES += main.cpp\
mainwindow.cpp \
cellcounter.cpp
HEADERS += mainwindow.h \
cellcounter.h
FORMS += mainwindow.ui
DISTFILES += \
to-do.txt
How can I link the library or something like this, haven't found anything in the web right know.
I have checked my libs and found out that I do not have a libwep.so.5 but libwebp.so.6 and libwebp.so and libwebp.so.2, but I do not know how to fix it, install libwebp.so.5 or change something in my .pro file?
Looks like the version of OpenCV that you installed wants to link with an older version of libwebp (specifically version 0.4.4 which contains libwebp.so.5) than what you have installed (probably version 0.5.0-1). Some options are:
Downgrade libwebp to 0.4.4 and ignore libwebp 0.5.0-1 to avoid reverting back with future upgrades. This is probably not the best choice, but it is easy and would work unless you have other packages which depend on 0.5.0-1.
Manually download and build the 0.4.4 version of libwebp and install in a non-standard location. In this case, you would need to modify/use LD_LIBRARY_PATH to point opencv there. This is probably your easiest best option.
Download some more recent version of the OpenCV source and build it. It will find and link to your current libwep.so.6, if it is compatible. The latest version of OpenCV (as of this writing 3.1.0) is compatible. This option is the best option but the most involved as compiling OpenCV can be trivial or painful depending upon the features you want to include.
Now a comment about your currently marked solution: Making a link from one soname to another is highly not recommended. In many cases, it won't compile, but even if it does, your application may exhibit arbitrary and unstable behavior and/or segfault unless the binaries are completely compatible. But if they were compatible, the packager would probably not have changed the soname. If this is for a school project, you might be ok, but if this is for anything important, don't do it.
Hope this helps.
I solved the problem with a not so elegant solution:
I just created a symbolic link:
$ file libwebp.so.5
libwebp.so.5: symbolic link to libwebp.so.6.0.0
with:
ln /usr/lib/libwebp.so.6 /usr/lib/libwebp.so.5

In an autotools project how do I specify the installation order of libraries?

I find this issue is seen only when I am building shared libraries.
Here is the exact issue:
In main.mk:
lib_LTLIBRARIES += libone.la
libone_la_LIBADD =
In dir-one/automake.mk:
...
libone_la_LIBADD += libtwo.la
...
In dir-two/automake.mk:
...
libone_la_LIBADD += libthree.la
...
In Makefile.am:
include main.mk
include dir-one/automake.mk
include dir-two/automake.mk
While make runs fine, make install complains that linker cannot find -ltwo and -lthree.
So:
lib_LTLIBRARIES += libthree.la libtwo.la libone.la
should give you the right install order.

How to compile vlc-qt libraries in BeagleBoneBlack

I'd like to compile VLC-Qt for BeagleBoneBlack.
To do this, I did these steps:
first of all, I downloaded vlc-qt source codes from here.
then, I move these codes to /home/debian/vlc-qt-0.90.0,in BBB
I created a folder, named "qtvlc" in "vlc-qt-0.90.0" folder.
I moved Qt5.2 Beaglebone Binaries,to qt-5.2 folder in
/home/debian/qt-5.2
added "SET(CMAKE_PREFIX_PATH /home/debian/qt-5.3.2") to
vlc-qt-0.90.0/CMakeLists.txt
cd to /vlc-qt-0.90.0/qtvlc and then type cmake ..
make
make install
ldconfig -v
After doing these steps, Compilation successfully done and libraries successfully placed in /usr/local/lib folder.
This is my pro file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
##===================
INSTALLS += target
TARGET = beagleplot
target.files = beagleplot
target.path = /home/debian
unix:!macx: LIBS += -L/usr/local/lib/ -lVLCQtCore -lVLCQtWidgets
INCLUDEPATH += /usr/local/include
DEPENDPATH += /usr/local/include
Now, when I'm trying to compile this project, I receive:
/usr/local/lib//libVLCQtCore.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
I have to note that, other programs run fine on BBB. but when I add a path to VLC-qt libs I receive this error.
Please help me what should I do?

How to add a new library using Yocto

I am using Yocto and I just would like to integrate a new library in my project.
I create a new recipe name "libxerces" which contains a file "libxerces-3.1.1.bb". The bb file is quite simple because it is based on autotools :
DESCRIPTION = "Xerces-c is a validating xml parser written in C++"
HOMEPAGE = "http://xerces.apache.org/xerces-c/"
PRIORITY = "optional"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
PR = "r1"
SRC_URI = "http://mirror.bit.edu.cn/apache//xerces/c/3/sources/xerces-c-${PV}.tar.gz"
s="${WORKDIR}/xerces-c-${PV}"
inherit autotools pkgconfig
SRC_URI[md5sum] = "6a8ec45d83c8cfb1584c5a5345cb51ae"
SRC_URI[sha256sum] = "a42785f71e0b91d5fd273831c87410ce60a73ccfdd207de1b805d26d44968736"
PACKAGES =+ "${PN}-utils"
FILES_${PN} = "${libdir}/*.so"
FILES_${PN}-utils = "${bindir}/*"
FILES_${PN}-staticdev = "${libdir}/*.a"*
BBCLASSEXTEND += "native"
I added "libxerces" to my bb image by using IMAGE_INSTALL += " libxerces". Then, I try to build my image thru bitbake my-image-test and eveything is done correctly but libxerces returns an error because it can not be installed. Howerver, I note that libxerces-dbg, libxerces-utils, libxerces-samples are visible under /tmp/work/deploy/ipk. I know that libxml2 is integrated by default into poky layer but I have to use xerces..
I solved the error
ERROR: Unable to install packages.
Collected errors:
* opkg_install_cmd: Cannot install package libxerces.
overriding the PACKAGES variable.
In your case:
PACKAGES = "${PN} ${PN}-utils ${PN}-staticdev"
I think that is because the .so files goes to ${PN}-dev package by default.
I hope there is a smarter solution, but for now I fixed in this way.
If you are building a library and the library offers static linking, you can control which static library files (*.a files) get included in the built library.
The PACKAGES and FILES_* variables in the meta/conf/bitbake.conf configuration file define how files installed by the do_install task are packaged. By default, the PACKAGES variable includes ${PN}-staticdev, which represents all static library files.
FILES_${PN}-staticdev ="" # for static libs
FILES_${PN}-dev ="" # for dynamic libs
FILES_${PN}-dbg ="" # for debug options
you need to add above line to your recipe

Resources