How to create a Qt executable for Linux machines
I have created a project using Qt 5.3. I want this project to run on other Linux machines, so I took the executable that was generated in the project build folder and ran it on another linux machine. When I did this I got the following error:
./Project_name: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
I have developed an application using QT 5.3, but the Linux machine where I am trying to start it has libqt4 libraries. Is there a way for this file to be executable using only libqt4 libraries. Below is my .pro project file:
#-------------------------------------------------
#
# Project created by QtCreator 2014-12-08T09:19:31
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Project_name
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
SOURCES += main.cpp\
mainwindow.cpp \
INCLUDEPATH += /usr/include/python2.7/
HEADERS += mainwindow.h
FORMS += mainwindow.ui
I checked online and found out that we need to change "largeThan (QT_MAJOR_VERSION, 4): QT + = widgets" to make it work for qt4 libraries. I did it, but it didn't work. So you could tell me what can be done so that a project that was built using libqt5 can also run on machines with libqt4. Installing the libqt5 libraries can be done, but I am looking for a way other than this.
source to share
Is it possible to run this file using only libqt4 libraries
Not easy at least ... Even if you created symlinks, Qt 4 and Qt 5 are not binary compatible.
If you want to make it self-contained:
-
Link libraries statically.
-
Use dynamic loading of symbols and based on the version you find you may need to program your code to act differently. But that can be a hell of a lot of work.
source to share