An error building Qt libraries for the raspberry pi - qt

I am trying to compile the Qt 5 libraries for my RPI, but it always crashes.
These are the guides I have tried to follow:
http://qt-project.org/wiki/RaspberryPi_Beginners_guide
http://qt-project.org/wiki/RaspberryPi
I have downloaded the cross-compiler and sysroot-image according to the guide and pulled the Qt5 sources from the git repo.
After following one of the guides I am now stuck at make.
This is the error I am receiving:
.obj/release-shared/qlibrary_unix.o: In function `QLibraryPrivate::load_sys()':
qlibrary_unix.cpp:(.text+0xf84): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): In function `dlopen':
(.text+0xc): undefined reference to `__dlopen'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlclose.o): In function `dlclose':
(.text+0x0): undefined reference to `__dlclose'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlsym.o): In function `dlsym':
(.text+0xc): undefined reference to `__dlsym'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlerror.o): In function `dlerror':
(.text+0x0): undefined reference to `__dlerror'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libm.a(feholdexcpt.o): In function `feholdexcept':
(.text+0x48): undefined reference to `_dl_hwcap'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libm.a(fesetenv.o): In function `fesetenv':
(.text+0x64): undefined reference to `_dl_hwcap'
collect2: virhe: ld:n paluuarvo oli 1 # collect2: error: ld returnvalue was 1
make[2]: *** [../../lib/libQt5Core.so.5.0.0] Virhe 1 # Error 1
make[2]: Poistutaan hakemistosta "/home/esa/qtonpi/qt5/qtbase/src/corelib" # Leaving directory
make[1]: *** [sub-corelib-make_first] Virhe 2 # Error 2
make[1]: Poistutaan hakemistosta "/home/esa/qtonpi/qt5/qtbase/src" # Leaving directory
make: *** [sub-src-make_first] Virhe 2 # Error 2

Fix the paths of the libraries in your sysroot. Some libraries are symlinks to absolute paths which are broken when placed in your system. Check something like /home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.so or similar. You should see those are broken symlinks to absolute paths. Fix all of those. In the documents you reported a script for this purpose is provided. Did you run it (https://gitorious.org/cross-compile-tools/cross-compile-tools/blobs/master/fixQualifiedLibraryPaths)?
Try also to check this if you still encounter troubles: I wrote down some notes compiling a recent version from the git for the wheezy image.

An answer for those who tried both the existing answers and they didn't work:
It might happen that the Raspbian image you downloaded doesn't contain symlinks for libdl and libdm in the /usr/lib/ folder.
In that case the fixQualifiedLibraryPaths won't help you as it can't find the symlinks. Copying libdl.so and libm.so might also fail, for example, if you use a flash drive to copy data from your existing Raspberry Pi, it won't copy them as symlinks, but will copy the libraries themselves. However, for the build to succeed, it seems to require symlinks.
I looked at what libdl and libdm in the /usr/lib/ folder of my Raspberry Pi point at
cd /usr/lib/arm-linux-gnueabihf/
ls -l libld.so libm.so
Do the same for the found files until they are no longer symlinks but normal files.
On my system it turned out they are called libdl-2.13.so and libm-2.13.so and reside in /lib/arm-linux-gnueabihf/ instead of /usr/lib/...
Going back to my PC, I found these exact files in the /lib/arm-linux-gnueabihf/ folder (if you don't find them, you can copy them from your Raspberry Pi). So I created symlinks for them in the /usr/lib/arm-linux-gnueabihf/ folder :
sudo ln -s /lib/arm-linux-gnueabihf/libdl-2.13.so /usr/lib/arm-linux-gnueabihf/libdl.so
sudo ln -s /lib/arm-linux-gnueabihf/libm-2.13.so /usr/lib/arm-linux-gnueabihf/libm.so
After this, qtbase was compiled successfully.
(note, that in order to continue to cross-compile from Qt, you have to
keep the image of your SD card mounted on your PC (as described in
the guide), but that's not enough: you have to mount it before
starting Qt Creator)

Try this
ln -s /mnt/raspberry-rootfs/lib/arm-linux-gnueabihf /lib/
Basically it seems that absolute path(s) have been specified when the so files on the Pi were linked (/lib/), and therefore in the /mnt/raspberry-rootfs they are broken.
Linking the Pi's /lib/arm-linux-gnueabihf to the Pc's /lib directory fixes the wrong linking and allows QT to compile. It's a dirty trick but it works.
If you don't have libdl/ libm on the Pi, then you need to stick the SD card back into the Pi, boot and install them. Obviously you will need to create a new image on the PC from the SD Card and mount it on /mnt/raspberry-rootfs

This could be because libdl.so and libm.so are missing from your local rootfs/usr/lib/arm-linux-gnueabihf directory (there are only libdl.a and libm.a). Copying the two files from the Raspberry Pi should make the compilation successful.

instead of fixQualifiedLibraryPaths use:
cd <folder-with-sysroot-subfolder>
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/script/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py
./sysroot-relativelinks.py sysroot

Related

Netcdf-Fortran failure when installing: netcdf-fortran-4.5/nf03_test

I am desperated and hope someone might be able to bring some light on this problem:
I am trying to install netcdf-fortran in Fedora 35 using Intel compilers. To do so, I first installed ONEAPI from intel in /opt/intel/oneapi. Then, I install
https://gmplib.org/download/gmp/gmp-6.2.0.tar.lz
https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz
https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz
git clone https://gnu.googlesource.com/gcc
git checkout releases/gcc-10
source /opt/intel/oneapi/setvars.sh intel64
export PATH=/opt/intel/oneapi/compiler/2021.4.0/linux/bin:$PATH
export LD_LIBRARY_PATH=/opt/intel/oneapi/compiler/2021.4.0/linu/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/opt/intel/oneapi/compiler/2021.4.0/lib/pkgconfig:$PKG_CONFIG_PATH
export C_INCLUDE_PATH=/opt/intel/oneapi/compiler/2021.4.0/linux/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/opt/intel/oneapi/compiler/2021.4.0/linux/include:$CPLUS_INCLUDE_PATH
Then exported the utilities directory where I am install all these packages and exported it accordingly.
Then, I kept installing:
szip-2.1.1.tar
libjpeg-turbo-2.1.2
gzip-1.11
bzip2-1.0.8
libuuid-1.0.3
brotli
gperf-3.1
gettext-0.21
hdf-4.2.15
hdf5-1.13.0
netcdf-c-4.8.1
and up everything compiles and works fine. Yet, when I tried to install
https://downloads.unidata.ucar.edu/netcdf-fortran/4.5.3/netcdf-fortran-4.5.3.tar.gz
Then it keeps failing and failing with the error:
make[3]: * [Makefile:728: test-suite.log] Error 1
make[2]: * [Makefile:836: check-TESTS] Error 2
make[2]: Leaving directory '/SOME/LOCAL/ADDRESS/netcdf-fortran-4.5.0/nf03_test'
make[1]: * [Makefile:917: check-am] Error 2
make[1]: Leaving directory '/SOME/LOCAL/ADDRESS/netcdf-fortran-4.5.0/nf03_test'
I don't know what the problem is but it is not a problem with the version as even if I install an older version, the error keeps being the same.
I tried to follow the instructions I was finding about how to install these libraries.
Can someone please give me an advice on how to do this?
My configure is as follows:
CC=icc FC=ifort F77=ifort CPP="icc -E" ./configure --prefix=$PRFX --with-sysroot=$PRFX --with-pic
I have defined:
PRFX=/SOME/LOCAL/ADDRESS/
Thank you in advance,
When you say "... and up everything compiles and works fine." did you mean that you compiled all those packages with ONEAPI? or did you just install those from the depository?
It is much predictable to install netcdf-f when all other dependencies are compiled with a same compiler. Or you should refer to cross-compilation for all required dependencies.
Did you compile hdf5 and netcdf-c (which are one of the basic dependencies for netcdf-fortran) with the ONEAPI? If not, I recommend you doing that first.
I realized that using different compiler than GCC when compiling netcdf-fortran generates an error regarding shared library. You should try compiling it with static library by adding "--disable-shared --enable-static" during the "configuration" stage (for detailed instructions, consult the "Building with static libraries" sections of this link). Make sure you explicitly link the 'include' and 'lib'
directories when you are using the netcdf-f library.

Build a QT program from command line

I know this question has already been asked, but I encounter an issue that I haven't seen elsewhere.
I am trying to build automatically a QT program on Jenkins through a JenkinsFile.
So I want to build this program in command line.
On Qt Creator, everything works fine, my makefile is generated and the program compiles.
But when I manually type the exact commands that are executed in Qt on a terminal (cmd and cygwin), the compilation fails.
The errors are usually ld: cannot find -lXXXXXX
My guess is that it is an environment problem so I tried to add some lib paths in the $PATH, $LIBRARY_PATH, and $LD_LIBRARY_PATH variables but it doesn't resolve the problem. The error just becomes Undefined reference to ___XXXXXX
I would appreciate some help on this issue !
Thanks.
EDIT
The building (slave) machine is a windows 7. Here is a screenshot of the compilation stage in Qt (which works fine). The commands I try to type in a terminal are exactly the same as the blue lines on the screenshot. (sorry some lines are written in French)
From the error message ld: cannot find -lXXXXXX and the environment variables, I would suppose that you are compiling in Linux/Unix. Now, if you are compiling with g++, the environment variables $PATH, $LIBRARY_PATH, and $LD_LIBRARY_PATH won't have any effect on finding libraries. What you may try is an -L argument to the compiler telling it where the library is located, I mean:
g++ -L /path/to/libXXXXX.so -l XXXXX -o result source.cpp

pcl/pcl_config.h: No such file or directory

My environment is below.
・Operating System and version:windows 10 64bit
・Compiler:C:\msys64\mingw64\bin\g++.exe
・PCL Version:1.9.1
pcl_config.h not found as below error occurred when compiled under above env..
Certainly this header file is not included.
Let me know how to solve it.
PS C:\pcl\pcl\examples\common> g++ -o minmax -I ../../io/include -I ../../common/include .\example_get_max_min_coordinates.cpp
In file included from ../../common/include/pcl/PCLHeader.h:10,
from ../../common/include/pcl/point_cloud.h:47,
from ../../io/include/pcl/io/pcd_io.h:42,
from .\example_get_max_min_coordinates.cpp:2:
../../common/include/pcl/pcl_macros.h:64:10: fatal error: pcl/pcl_config.h: No such file or directory
#include
^~~~~~~~~~~~~~~~~~
compilation terminated.
Short answer
pcl_config.h is generated via pcl_config.h.in by the cmake tool. So it seems that compilation did not finish correctly.
Longer answer
Please make sure you have compiled the relevant modules of PCL (at least pcl-core) before proceeding
You might prefer a pre-built installation from releases or distributed by a package/source manager of your choice
PCL makes heavy use of other libraries and it is best to supply the dependencies (as mentioned below) via CMake or manually via the -I and -l options. If you provide the location of pcl_config.h, the compiler will complain about Eigen next.
The build instructions are available here. TL;DR: After satisfying the dependencies (cmake, c++ compiler, boost, eigen, flann, vtk and other depending on use-case), run the following commands
cd $PCL_SOURCE_DIR
mkdir -p build; cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j8
Feel free to use any build generator (like Ninja) or change build type to Debug or RelWithDebInfo as per your needs.

Unable to compile AdaControl: unknown project file: "asis"

I downloaded the source for AdaControl from the SourceForge Repo. Using GNAT 2017 CE, I get the following error on make:
$ make build
gprbuild build.gpr adactl -cargs -bargs -largs
build.gpr:1:06: unknown project file: "asis"
gprbuild: "build.gpr" processing failed
make: *** [adactl] Error 4
The instructions make it sound like this is all I need to do, and offer no troubleshooting suggestions:
Go to the root directory of the distribution and type:
make build make install
As this related question notes, I have managed to get ASIS to build, though it also comes packaged with GNAT 2017 CE.
That message means that ASIS4GNAT isn't installed in a place where gprbuild (and the rest of your GCC/Ada tool-chain) can find it.
You can use the command gnatls -v to get an idea about where your GCC/Ada tool-chain expects project files to be located.
Compare that to where you actually installed ASIS4GNAT, and you may be closer to a solution.

Changing the path to a dynamic library in an executable

I'm building my program with clang and its using an external library. I've been developing for a while with the binaries they provided (/usr/lib/libary.so), but I now want to move over to a more current version.
I downloaded the source code and built it, resulting in an include file and a new library (in my ~/library/build directory).
When compiling my code, I use
clang++ main.cpp -I ~/library/include -L ~/library/build/lib -llibrary
This includes the up to date header, and finds the correct library (I know it finds the correct library, because without the -L flag, I get an error saying 'undefined reference to NewlyIntroducedFunction').
However, when I try to run a.out, I get the error:
./a.out: symbol lookup error: ./a.out: undefined symbol: NewlyIntroducedFunction
Running ldd on ./a.out shows me the line:
library.so => /usr/lib/library.so
So I assume that, although at compile time the correct library is being used, at runtime it isn't. I added ~/library/build to the start of PATH and that didn't work.
What do I do to get the correct version of library.so found?
Your LD_LIBRARY_PATH variable (library search path) is probably not correct

Resources