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

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.

Related

Adding .so and symlink to .so in Yocto

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.

How does one set a C/C++ include path with Gradle Experimental Plugin?

Android Studio cannot find my header files when they are in a location different to the main source folder of my module. This is noticeable by #include "SDL_config.h" statements being highlighted in red (other #include statements are fine).
I have tried modifying the cppFlags values below but I am starting to doubt that these cppFlags are even being passed to the compiler at all.
Has anyone managed to include files from folders other than their main source folder in this way?
Is there a problem with the way I have specified the cppFlags, or perhaps the moduleName or even sources?
I could go through the SDL2 source and modify all of the #include statements to relative #include paths but I don't really want to modify the SDL2 source. I should simply be able to specify a list of include paths somehow.
apply plugin: 'com.android.model.application'
model {
...
android.ndk {
moduleName = 'main'
//W:\hello-sdl-android\android-project\app\src\main\jni\SDL2\include
cppFlags += "-I${file("src/main/jni/SDL2/include")}".toString()
cppFlags += "-I${file("src/main/jni/SDL2/src")}".toString()
}
android.sources {
main.jni {
source {
srcDirs += ['src/main/jni/src']
srcDirs += ['src/main/jni/SDL2/src']
}
}
}
...
}
UPDATE: Here's more information on my current project layout:
app/src/main/jni
app/src/main/jni/src/Main.cpp <- This is compiling
app/src/main/jni/SDL2 <- All SDL2 source is under here
app/src/main/jni/GLM <- All GLM source is under here
This layout is a direct result of using the example project which I was provided here: https://gitlab.com/scannerdarkly/hello-sdl-android
That project will build using ndk-build from the command line - I wanted to take things a step further by building within Android Studio. My project will attempt to draw a triangle on a GLES2 device.
Here is a link to my current project so far:
http://www.mediafire.com/download/92577p7vf123l72/hello-sdl-android.zip
I use a slightly different approach:
cFlags += "-I" + file("src/main/jni/SDL2/include").absolutePath
.. and this works. The reason is probably that the compiler is launched with a different working directory, and absolutePath resolves any ambiguity here.
Yes! I figured it out - SDL2 source files are .C files, so include paths need to be declared using CFlags, not cppFlags.
Here is another style for more header paths using the gradle experimental plugin, example with openssl and some "abc" library:
// compile parameters
// include openssl headers C (if you have C files)
CFlags.add("-isystem${project.rootDir}/external-libraries/openssl/openssl-1.0.2g/include".toString())
// include openssl headers C++ (if you have cpp files)
cppFlags.add("-isystem${project.rootDir}/external-libraries/openssl/openssl-1.0.2g/include".toString())
// include abc headers C (if you have C files)
CFlags.add("-I${project.rootDir}/external-libraries/abc/abc-5.5/include".toString())
// include abc headers C++ (if you have cpp files)
cppFlags.add("-I${project.rootDir}/external-libraries/abc/abc-5.5/include".toString())
// linking parameters
// link libcrypto.so
ldFlags.add("-L${project.rootDir}/external-libraries/openssl/openssl-1.0.2g/lib/armeabi-v7a".toString())
ldLibs.add('crypto')
// link libabc.so
ldFlags.add("-L${project.rootDir}/external-libraries/abc/abc-5.5/lib".toString())
ldLibs.add('abc')
for many header paths :
cFlags = "-I" + file("src/main/jni/path1").absolutePath +
" -I" + file("src/main/jni/path2").absolutePath +
" -I" + file("src/main/jni/path3").absolutePath

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

Raspberry Pi bcm_host include directories

I'm trying to write a simple program that uses EGL, but when I include bcm_host.h, gcc says it doesn't exist, so I add /opt/vc/include to the makefile, it says that another header is missing, I add another directory, and now, after 6 folders, I don't really want to do it anymore but gcc wants more. I have looked at the /opt/vc/src/hello_pi/Makefile.include file, and it adds just 3 folders. So the question is: what am I doing wrong?
Here's the makefile:
LIB_DIR = -L/opt/vc/lib
INCLUDE_DIRS = -I/opt/vc/include -I/opt/vc/include/interface/vcos/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmc_host/linux -I/opt/vc/include/interface/vmcs_host -I/opt/vc/include/interface/vchi -I/usr/include/SDL -I-
LIBS = -lSDL
bin:
gcc $(LIB_DIRS) $(INCLUDE_DIRS) $(LIBS) main.c
I included bcm_host.h in a project where I was using code from the dispmax example. I have very similar makefile settings, with the exception that I added -lbcm_host as a library:
# Include the Broadcom hardware interface library
XINCDIR += /opt/vc/include
XINCDIR += /opt/vc/include/interface/vcos/pthreads
XLIBS += -L/opt/vc/lib/ -lbcm_host
That worked for me, although I wasn't trying to use EGL specifically. You probably need -lEGL instead or in addition.

Resources