Run Binary With Specific QT Version - Cannot mix incompatible Qt library - qt

I'm trying to replicate an application that we currently have running on a physical Ubuntu server using an Ubuntu machine in Virtual Box. It is a QT application but on the server we are running it using pm2 from NPM. After installing QT, and installing drivers needed for the application i've tried to run it but keep coming across this error:
Cannot mix incompatible Qt library (version 0x50701) with this library (version 0x50905)
I've inherited the code from someone else and don't want to change the project to QT5.9.5, so i'm trying to run with 5.7.1, I've followed instructions on other questions in order to change the QT version to 5.7.1 but still get the same error when running it.
I followed the instructions here:
https://unix.stackexchange.com/questions/116254/how-do-i-change-which-version-of-qt-is-used-for-qmake
When checking the QT version using "qmake -v" in the console I get the following output:
QMake version 3.0 Using Qt version 5.7.1 in /home/sam/Qt5.7.1/5.7/gcc_64/lib
So although it looks to me like i'm using the desired version of Qt (5.7.1), i'm still getting the incompatible library issue, i'm very new to all of this so apologies if this is a stupid question. If anyone could tell me what to do in order to use the compatible library that'd be great, thanks.

I will try to explain this in steps!
Each complete set of Qt libraries is called a Qt "distribution". You can get Qt distributions from a variety of sources:
Installed from the package manager of your OS (.deb/.rpm).
From a downloaded zip file on http://qt.io
As a cloned repo from git
etc..
Some of the available Qt distributions will come pre-built, and some will need to be built from sources. In either case they will all have a qmake program that is specific to that particular Qt distribution. This program is responsible for building programs so that they link to the particular Qt distribution that the qmake is part of. qmake is also used when building with QtCreator.
If you have a binary built with one qmake and you try to run it on another computer, it might find the wrong Qt libraries during dynamic linking and spit out errors of "incompatible version of Qt".
There are many solutions to this problem;
Collect all the Qt libraries (Mine are in /home/myusername/Qt/5.version/gcc_64/lib/*.so) in the same folder as your program executable. This will make sure they are prefered to any other version of Qt that may be in your dynamic linker's path.
Uninstall the OS supplied Qt version(s). This may not be advisable especially if other programs use them.
Rebuilt your program from source using the correct qmake.

Related

Where is the Qt binary file?

I'm on Manjaro based on Arch Linux.
I searched everywhere, and I cannot seem to find that binary file.
Searched /usr/lib/qt, used find and which commands, etc.
The only might-be relevant thing I found is in /usr/lib/qt6/bin/, I found a binary file called "qt-cmake". But I'm pretty sure that's not what I'm looking for.
My final goal is to install the latest release version of Qt Creator on GitHub, and installation needs to know the paths of two binary files :
Qt
Llfw
Installation guide precisely says "These instructions assume that Ninja is installed and in the PATH, Qt Creator sources are located at /path/to/qtcreator_sources, Qt is installed in /path/to/Qt, and LLVM is installed in /path/to/llvm."
There is no "Qt binary file" per se. Qt is a framework, delivered as a (large) group of libraries and header files.
The Qt installer should provide you with everything you need. I'm not sure this link will work for you, but...
Qt Installer
As an aside, Qt Creator is an IDE for building and testing Qt-based applications. It isn't clear to me why you'd need the sources for that.

Cannot mix incompatible Qt library (version 0x50501) with this library (version 0x50201)

I have installed Shadowsocks-Qt5 within the code sudo apt-get install shadowsocks-qt5 in terminal, and then I can find the launch icon by searching, but it won't open when I click the icon. Then I tried to use terminal to open it, but the error comes out as below:
~ ss-qt5
Cannot mix incompatible Qt library (version 0x50501) with this library (version 0x50201)
[1] 8875 abort (core dumped) ss-qt5
I searched many answers but no one work. I think the key may be the default Qt library, but I don't know how to set default Qt library, the system on my computer is Ubuntu 14.04 LTS.
How to solve this problem?
I just had this error when attempting to run Qt Creator after doing a system update. For me, I was attempting to run Qt Creator 4.10.0-rc1 (based on Qt 5.13.1) that I had manually installed to ~/Qt along with Qt 5.13.0, and my system has Qt 5.12.2 installed.
I was getting the following error:
Cannot mix incompatible Qt library (version 0x50c02) with this library (version 0x50d00)
Doing an strace when running qtcreator.sh revealed that it was attempting to load plugins from the system directory. I finally discovered the culprit was the environment variable QT_PLUGIN_PATH was set (in my case to /usr/lib64/qt5/plugins:/usr/lib64/qt5/plugins/kcms).
After unsetting this variable, Qt Creator started up and worked.
After so many months of trying to fix this issue, this helped me.
sudo apt install qt5-style-plugins.
I was facing a similar issue, and even after 4 hours of debugging, I got nowhere. Finally, I found the following way to keep separate Qt versions, posting here so that other people find it.
Suppose you installed Qt in ${QtRoot}, extend the PATH and LD_LIBRARY_PATH:
export PATH=${QtRoot}/bin:${PATH}
export LD_LIBRARY_PATH=${QtRoot}/lib:${LD_LIBRARY_PATH}
You can make a wrapper function / script to manage separate Qt installations like this:
QtVersion=5.12.8
QtRoot="/scratch/Qt/${QtVersion}/gcc_64"
export PATH=${QtRoot}/bin:${PATH}
export LD_LIBRARY_PATH=${QtRoot}/lib:${LD_LIBRARY_PATH}
After running this your application will likely run fine.

Cannot cmake kde-connect

I am trying to install kde-connect following this.
Although my kubuntu version is 14.04, I wanted to compile them so that I can have the latest version. But when I followed the instructions to compile, i get the following error.
-- Found Qt-Version 5.2.1 (using /usr/bin/qmake)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
QT_QT_INCLUDE_DIR
used as include directory in directory /home/vinaychandra/Downloads/t/CMakeFiles/CMakeTmp
CMake Error: Internal CMake error, TryCompile configure of cmake failed
CMake Error at /usr/share/kde4/apps/cmake/modules/FindKDE4Internal.cmake:1311 (message):
Unable to compile a basic Qt application. Qt has not been found correctly.
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindKDE4.cmake:95 (find_package)
CMakeLists.txt:7 (find_package)
Please point out how to correct this.
I have tried giving -DQT_QT_INCLUDE_DIR=/usr/share/qt4/
then it tells that You must build your code with position independent code if Qt was built with -reduce-relocations.
Your cmake by default uses a different QT version.
So, you must explicitly tell him which version of QT he have to use for this job.
This one
-DQT_QT_INCLUDE_DIR=/usr/share/qt4/
Is wrong because you mustn't give QT position explicitly.
All you need is to use the right qmake.
So, give'em this flag and you'll be happy!
-DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4
Since most of kde applications are not ported to Qt5, you need Qt4.x for building kdeconnect(don't know x, mine is 4.8.6).
Also Qt4 installer is not available (I think !), so you have to build it also from source. Building Qt4 is quite easy, just download the source and run the usual commands.
After building it, it qmake name will be qmake-qt4 in /usr/bin.
So for building kdeconnect, first run its cmake, then a Cmaketextcache.txt file will form.
In that change the path of qmake (i.e somewhere written /usr/bin/qmake to /usr/bin/qmake-qt4) and also the path of qt include dir to (I think /usr/include/qt5 to /usr/include/qt4), and run the cmake again.
If some packages are missing, then you have to install it.
But with the above changes, you will get a make file to install it.
Unfortunately, the cited documentation is lagging behind the current state of kdeconnect. I ran into similar problems but I managed to solve them by installing the following required packages from the Kubuntu repositories:
sshfs
libfakekey-dev
libxtst-dev
libqca2-dev
libqjson-dev
I trust these are all of them. I installed kdeconnect from the latest git commit and it seems to run fine.
This answer comes a bit late, but this is the first Google search result for the question. In systems with qtchooser (Kubuntu, Ubuntu at least), this can be fixed by running first:
export QT_SELECT=qt4
This makes all of the Qt build tools to default to the Qt4 version instead of Qt5. You can check which Qt version is active by running:
qmake --version
Try kde connect install on ubuntu: https://fazlerabbi37.github.io/blogs/install_kde_connect_in_ubuntu_18.04.html
(in 18.04 & 19.04 it works with simple sudo apt install kdeconnect
Install kde connect on android device (google play store is where I installed from)
Invoke kde connect from desktop
Invoke kde connect from android and search device.
Your ubuntu will be found / initiating a search from desktop results in android phone pulled up for pairing
Accept pairing request
Provide access to folders
Try clicking on a video/image file for transfer
I could see the new file transferring in /Downloads folder of desktop
allowing/disallowing desktop to access sms, notifications etc are now a choice
Note: Pl treat this with pinch of salt. This appears very simple, effective for a main reason it worked for me in no time.

How to run a Qt application on a system where Qt is not installed?

I have made an application using QtWebKit, Qt4. I have the binary generated in Fedora 16. Now, I want to run that application on another PC (running some other Fedora version), where Qt is not installed. How can I package my Qt application so that it can run on a platform where Qt is not installed? Is there any command line utility as well as QtCreator utility to do so. I have tried "deploy all" command, but it didn't have any affect.
Create an Installer with the Qt Installer Framework and just supply all needed shared libraries (Win/OSX) or compile statically. Under Linux there is always the problem between system-wide libraries or bundled libraries. The documentation https://qt-project.org/doc/qt-5.0/qtdoc/deployment.html should give you a good start
Obviously, you need to have access to the qt libraries, which are exactly the same version that you used to compile your application.
There are two options :
link qt libraries statically
create a RPM package (see this how)
Also check Deploying Qt Applications.
Since you're deploying using rpm, to systems where Qt 4 rpms are available, you don't need to do anything besides simply adding a dependency on the qt to your rpm's specfile. The user installing your package using yum localinstall will get the Qt dependencies automatically installed. That's the correct way of doing it - it will keep your package size small.
Of course you need a separate rpm build for every fedora/centos major version out there, but that's almost always a requirement.
If your package needs newer Qt version than the one provided by the platform packages, you can still make a specific version dependency (say qt >= 4.7.0) and have a readme that indicates that newer packages can be obtained from a 3rd party repository (epel etc.)
For deployment under Linux I've used Bitrock Installer Tool.
The main thing before deploying is to check your dependencies. You can do that by using command:
ldd appName | grep libQt
After that you'll see list of dependencies. You'll have to set environment variable LD_LIBRARY_PATH to let linker know where're your libraries. To do that:
export LD_LIBRARY_PATH=.
. means current directory
And after that:
./appName $*
After that you'll be able to use your executable with Bitrock Installer Tool.

Qt 4.8.3 installation on Windows 7 & QtWebkit problems

I just updated my Qt to 4.8.3, because the program built from older version is not compatible to the new framework.
So I have to upgrade.
This process was frustrating and time consuming. So many problems came out.
I download Qt from this url:
http://qt-project.org/downloads
At beginning, I installed the MinGW one (I'm not a fan of MSVC).
I tried the newest ( I think it's 4.6) version of MinGW and order version (4.4).
However, after I installed MinGW and tried to install Qt 4.8.3, during the process, the following message shows up:
There is a problem with your MinGW installation:
The installer could not find a valid C:\MinGW\include\w32api.h (Only versions with W32API 3.13 are supported)
Do you still want to continue? (Your installation may not work)
The 4.6 version does have this w32api.h file, I don't know what's going on. And I have trouble finding MinGW 4.4 with this head file.
I decide to ignore this warning and continue to install Qt and Qt creator. After that,
I opened my current project, configure it (why the configuration become so complex...), I tried to build it.
Then the following message shows up because some external lib I used requires Exception Handling:
exception handling disabled, use -fexceptions to enable
And I don't know how to enable the it.
I tried to add -fexceptions flag in QMAKE_CXXFLAGS but it doesn't work.
By the way, I tried the VC version of Qt too, but I used the MinGW before and the VC compiler is quite different, if I use VC version, it will take a lot of time to make it compilable by VC compiler.
Does anyone know how to install Qt 4.8.3 on Windows? my project works fine before, now I just want to compile it successfully.......
These are not the only problem.
I updated the Qt on Mac machine too, it is easier to have the compiler work since it's unix base.
However, I used QtWebkit lib in my project and obviously, they changed this lib and it's not compatible to order version.
I can compile my project on Mac, however, every time I run it, following massage shows up and the program stopped.
dyld: Symbol not found: _OBJC_CLASS_$_CALayerHost Referenced from:
/Library/Frameworks/QtWebKit.framework/Versions/4/QtWebKit Expected
in:
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
The program has unexpectedly finished.
Does any one know how to solve this QtWebKit problem? I'll really appreciate.
I remembered that when Qt is under nokia, it's so easy to install and use, the Qt SDK is perfect.
I really hate the change made after it was bought by digia.........
I found solutions of my first two problems:
for the first problem, as I described, download the MinGW provided by Nokia Qt
ftp.qt.nokia.com/misc/MinGW-gcc440_1.zip [ftp.qt.nokia.com]
Tried several versions of MinGW 4.4, I think this is the only one works.
About the second problem, add following configure in the project file:
CONFIG += exceptions
Now the QWebKit problem is only one unsolved.
Is it all relevant that your include directory for MinGW has two "i's" in it or was that a typographic error when posted on SO? See:
The installer could not find a valid C:\MinGW\iinclude\w32api.h

Resources