qmake searching for library in absolute path - qt

I am cross-compiling a Qt Application. My host is a Ubuntu system and target is ARM board with buildroot based filesystem and I am using Qt 5.3.1. When I try to run make, I get the following error:
/home/hamzah/vibrante/toolchains/tegra-4.8.1-nv/usr/bin/armv7a-vfpv3-cortex_a15-linux-gnueabi/../../libexec/armv7a-vfpv3-cortex_a15-linux-gnueabi/gcc/arm-cortex_a15-linux-gnueabi/4.8.1/ld: cannot find /lib/libpthread.so.0
/home/hamzah/vibrante/toolchains/tegra-4.8.1-nv/usr/bin/armv7a-vfpv3-cortex_a15-linux-gnueabi/../../libexec/armv7a-vfpv3-cortex_a15-linux-gnueabi/gcc/arm-cortex_a15-linux-gnueabi/4.8.1/ld: cannot find /usr/lib/libpthread_nonshared.a
collect2: error: ld returned 1 exit status
As you can see, it is using absolute path in target for libpthread.so.0 and libpthread_nonshared.a. This library is placed in the target filesystem hosted on my host. The target library search path has been added in qmake.conf using QMAKE_LIBDIR variable:
QMAKE_LIBDIR += /home/hamzah/buildroot/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot
QMAKE_LIBDIR += /home/hamzah/buildroot/output/host/usr/arm-buildroot-linux-gueabihf/sysroot/usr/lib
I need to know how to make the ld able to find this library using sysroot variable or any other approach.
PS: I am compiling Qt Application. Pre-built Qt applications are running on both my host and target

Use the qmake built by Buildroot in output/host/usr/bin. This one has the right paths pre-configured. If it still doesn't work, please submit a bug report in the Buildroot bug tracker, with a simple test case to reproduce the problem, as well as the list of steps to reproduce it.

Related

grpc_out: protoc-gen-grpc: Plugin failed with status code 1

I have cross compiled gRPC (v1.27.3) for QNX 7 (ARM) platform. I am using the protobuf which was already available for our system (QNX ARM v3.11.4).
I used following cmake command to build gRPC for compilation process
cmake -DCMAKE_CROSSCOMPILING=1 -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DOPENSSL_CRYPTO_LIBRARY=$QNX_TARGET/aarch64le/usr/lib/libcrypto.a -DOPENSSL_SSL_LIBRARY=$TARGET/aarch64le/usr/lib/libssl.a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/tmp/qnxarm/toolchain.cmake -DCMAKE_INSTALL_PREFIX=/tmp/qnxarm/inst ../..
make plugins
make -j4
sudo make install
After compiling, I am able to see the binaries in /tmp/qnxarm/inst folder.
I copied those binaries in our code to compile the application for QNX.
While compiling I am getting this issue:
<local_directory>/grpc/aarch64/qnx/bin/grpc_cpp_plugin: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.
lib/qmonitor/proto/CMakeFiles/QMonitorProto.dir/build.make:105: recipe for target 'lib/qmonitor/proto/QAicMonitorInternal.grpc.pb.cc' failed
make[2]: *** [lib/qmonitor/proto/QAicMonitorInternal.grpc.pb.cc] Error 1
Please help me to know what is wrong? or what should be done to solve this.
Do we need to add the PATH in gRPCTargets.cmake file which is generated in lib folder?
You've compiled the gRPC tools for your QNX ARM system -- so the version of grpc_cpp_plugin you made is expecting to be run on your QNX system, not your build host.
The usual approach for this sort of thing is to make a second copy of gRPC compiled for your build host, and then instruct your application build to link the libraries from the cross build, but call the grpc_cpp_plugin compiled for the build host.

Conan-based Qt installation uses wrong home dir for linking

I'm trying to build our application using Qt 5.13.0 installed via Conan/Artifactory. We run our own Artifactory server and the Qt version there is self-build (and statically linked) in our CI solution. We use the Conan recipe for Qt written by the bincrafters, slightly modified to apply some patches for known Qt bugs and set some flags for building properly on Android and WebAssembly.
When trying to build the application, the linker fails to find the necessary dependencies for Qt itself because it tries to look them up in the home folder of the user who build the Qt package, not the user who's running the build.
Here's an excerpt from the build log, showing the attempt at linking all previously compiled object files together:
application folder-------v subproject of the application----v-------v dependency of the application, correct user home dir---------v Qt library installed via Conan, correct user home dir-------v dependency of Qt, WRONG user home dir------------v
g++ -Wl,--gc-sections -o ../../fah [--> all the .o files <--] -L../lib -lmodel -lcore [--> more linked libraries and application parts <--] -L/home/kaupes/.conan/data/libsodium/1.0.18/bje/stable/package/d1efe3774eed76670888f919621e7c4e1b52efa9/lib /home/kaupes/.conan/data/qt/5.13.0/bje/stable/package/d6b3f512e1a5607061462f94e3271dc8af3dd516/lib/libQt5Gui.a /home/dev/.conan/data/harfbuzz/2.4.0/bje/stable/package/c68551ae35bf5d62e66263379d58a38416eb84a9/lib/libharfbuzz.a [--> many, many more libraries <--]
g++: error: /home/dev/.conan/data/harfbuzz/2.4.0/bje/stable/package/c68551ae35bf5d62e66263379d58a38416eb84a9/lib/libharfbuzz.a: No such file or directory
many, many more errors...
As you can see, the user running the build is kaupes, but the g++ invocation attempts to look for the dependencies in /home/dev/, the home folder of the CI user who build the Qt Conan package.
Only dependencies of Qt itself have the problem. Dependencies of the application (also installed via Conan) are found at the correct place.
The Qt package has been build in the CI using the following Conan invocation:
conan create --profile .conan/profiles/linux -s compiler=gcc -s compiler.version=9 . fah/stable
Compiler and version are explicitly set because I'm also build for another GCC version. The linux profile file also doesn't do anything interesting (as far as I can see):
include(default)
[settings]
build_type=Release
compiler.libcxx=libstdc++11
[options]
OpenSSL:shared=False
OpenSSL:no_asm=True
OpenSSL:no_asm=True
OpenSSL:no_weak_ssl_ciphers=True
OpenSSL:no_ssl2=True
OpenSSL:no_ssl3=True
OpenSSL:no_engine=True
libcurl:shared=False
libxml2:shared=False
libxml2:fPIC=True
libsodium:shared=False
pcre2:shared=False
libpng:shared=False
freetype:shared=False
bzip2:shared=False
libjpeg:shared=False
harfbuzz:shared=False
xkbcommon:shared=False
qt:shared=False
qt:with_glib=False
qt:with_sqlite3=False
qt:with_mysql=False
qt:with_pq=False
qt:with_odbc=False
qt:with_sdl2=False
qt:with_openal=False
qt:with_libalsa=False
qt:openssl=True
qt:commercial=False
qt:qtsvg=True
qt:qtdeclarative=True
qt:qtactiveqt=False
qt:qtscript=False
qt:qtmultimedia=False
qt:qttools=True
qt:qtxmlpatterns=False
qt:qttranslations=True
qt:qtdoc=False
qt:qtrepotools=False
qt:qtqa=False
qt:qtlocation=True
qt:qtsensors=True
qt:qtwayland=True
qt:qt3d=False
qt:qtimageformats=False
qt:qtgraphicaleffects=True
qt:qtquickcontrols=True
qt:qtserialbus=False
qt:qtserialport=False
qt:qtx11extras=True
qt:qtmacextras=False
qt:qtwinextras=False
qt:qtandroidextras=False
qt:qtwebsockets=True
qt:qtwebchannel=False
qt:qtwebengine=False
qt:qtwebview=False
qt:qtquickcontrols2=True
qt:qtpurchasing=False
qt:qtcharts=True
qt:qtdatavis3d=False
qt:qtvirtualkeyboard=True
qt:qtgamepad=False
qt:qtscxml=False
qt:qtspeech=False
qt:qtnetworkauth=False
qt:qtremoteobjects=False
qt:qtwebglplugin=False
qt:qtlottie=False
qt:qtconnectivity=True
Is there something I'm doing wrong during the Conan package creation or installation or is this caused by something different?
Indeed, when building qt, all paths to dependencies are hardcoded in configurations files (mkspecs\modules\qt_lib_*.pri).
I assume you are building your application with qmake, because you use static qt, and static qt is incompatible with cmake. One thing you could try is to pass the full path to harfbuzz lib to qmake by adding argument QMAKE_LIBS_HARFBUZZ=/home/kaupes/.conan/data/harfbuzz/2.4.0/bje/stable/package/c68551ae35bf5d62e66263379d58a38416eb84a9/lib/libharfbuzz.a to your qmake invocation.
Edit: it seems to be a knwonw behaviour of qt >= 5.12.1 : https://bugreports.qt.io/browse/QTBUG-72903. This feature has been reverted in 5.14.x and 5.15.x with https://github.com/qt/qtbase/commit/9864d2c6f3b628ca9f07a56b197e77bd43931cca

How to set up poppler library in Qt for embedded device?

The goal is to show pdf's on my target => imx6 board + display. My host's OS is Linux.
So far i'm having a program written in Qt 5.
It compiles fine and i'm able to see it on the display.
To show some pdfs i would like to use the poppler library.
The problem is that i'm not able to get this done. Properly ...
My steps so far:
I did the basic installation of poppler like it is described in the INSTALL file.
mkdir build
cd build
cmake ..
make
make install
then added
INCLUDEPATH += /home/user/poppler/include/poppler/qt5
LIBS += -L"/home/user/poppler/lib" -lpoppler-qt5
to my .pro file
and the #include <poppler-qt5.h> to my .cpp file.
And the result when running is this:
/home/user/poppler/lib/libpoppler-qt5.so:-1: error: file not recognized: File format not recognized
:-1: error: collect2: error: ld returned 1 exit status
Now i have just two ideas. First one is to cross-compile the poppler source code. (I tried this with a toolchain file but failed :'D)
Second idea is to put the library into Qt together with my project and compile it there - maybe that could work. I just don't know how. Help.
I'm also open for something else then poppler - i just want to show pdf's.
The problem, here, is you are somehow compiling Qt projects for ARM, using the corresponding toolchain and sysroot and ABI, and you can not just link to libraries you compiled for, say, x86_64, because they're just binary incompatible.
In the very lucky case you managed to configure creator for cross compilation, just make a creator project for the poppler library, using cmake, and configure the project with the same kit you use for the imx6 applications. Once you have it built for ARM, you can proper link it in your app, providing the full path to LIBS in the .pro file.
In case you're using Yocto, instead, just make a recipe for poppler. In case you're not, maybe you should.

Error in OpenCV configuration for Qt Creator

I followed these instructions in the configuration of OpenCV SDK for using it in Qt Creator IDE, but I couldn't conclude point 6.5, due to configuration errors in Cmake-GUI. I setup the configuration in CMake of the compilers gcc and g++ contained in Qt folder for MinGW32, and all looks Ok. But when Cmake-GUI starts the process of build configuration it ends up saying
"Error in configuration process, project files may be invalid".
It can't find the following:
QT_QMAKE_EXECUTABLE;
Qt5Concurrent_DIR;
QT5Core_DIR;
QT5Gui_DIR;
QT5Test_DIR;
QT5Widgets_DIR.
After this issue I tried to go on with following points of configuration tutorial, without reaching the final instruction of mingw32-make install. I'm using the following versions of softwares: Qt 5.3.0, OpenCV 2.4.9, CMake 2.8.12.2. My OS is Windows 7.
How can I recover the missing Qt files in CMake configuration?
Is there an alternative way for configuring OpenCV with Qt (like using precompiled build of OpenCV libraries)?
You just need to indicate CMake the correct paths to each one. Click oh the path to browse and set each one individually:
QT_QMAKE_EXECUTABLE;
For this one, you need to search inside the Qt installation folder for the /bin directory. On it, you' ll find the qmake.exe. In my case it was C:/Qt/5.3/winrt_x64/bin/qmake.exe
All the following ones are in the Qt's /lib/cmake directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake :
Qt5Concurrent_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Concurrent
QT5Core_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Core
QT5Gui_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Gui
QT5Test_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Test
QT5Widgets_DIR.
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Widgets
Then click generate. It' ll show a new error and ask you for the QT5OpenGL_DIR. Just as before, show CMake the correct directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake/Qt5OpenGL. Finally, click Configure again, and then Generate, and now you're done creating the build files.
You have to specify the location of Qt manually by passing it as an argument for QT5Core_DIR. Qt5_DIR or CMAKE_PREFIX_PATH does also the trick.
Example
Given your Qt 5 is installed at /opt/selfcompiled/Qt5. When calling cmake, add the flag from above:
cmake -DQt5_DIR=/opt/selfcompiled/Qt5 <pathToSourceDir>
Once the Qt 5 directory is set and found by CMake, all the other variables related to Qt 5 should be found from there, too.

Cannot find -lQt5Guid and -lQt5Cored

I am currently trying to compile a Qt application that I downloaded from github on my windows machine. I did not have any trouble compiling this on Ubuntu so I was hoping someone could help shed some light on my problem.
I am using Qt-Creator to compile the program.
The exact error messages are:
:-1: error: cannot find -lQt5Guid
:-1: error: cannot find -lQt5Cored
collect2.exe:-1: error: error: ld returned 1 exit status
My first idea when reading those messages was that the windows PATH variable does not include the locations of the libraries. But when I checked, my PATH contained the following:
C:\Qt\Qt5.1.0\5.1.0\mingw48_32\bin;C:\Qt\Qt5.1.0\Tools\mingw48_32\bin;...
Which exists and contains what looks like the correct Dlls.
I am using MingGW rather than the visual studio compiler (although i have it available if needs be).
How can I fix this error and what could be causing it?
EDIT: When I run qmake there does not seem to be any problem. The errors come up when I try to build the project.
Cored is a fundimental part of Qt so it looks like the linker can't see any of the Qt libraries.
Did you install Qt 5.1.0 SDK?
A few things to check:
Do you have a line like this in your .pro file?:
QT += core
You mentioned "Projects section my path" are you talking about the windows PATH variable? these paths should also be in that. You can check with dos command:
echo %PATH%
If these paths are not there, for a test, add them in if this works then something has gone wrong with the local PATH setup (i.e. when running qt creator - if you are using qt creator?)
Finally just check that the debug version of the Qt5Cored.dll exists in that folder (C:\Qt\Qt5.1.0\5.1.0\mingw48_32\bin) because it looks like you are building a debug build (which is why your program is looking for 'd' post-fixed name Qt5Cored and not Qt5Core).

Resources