I have created a project using Qt 5.3. I want this project to be executable on other linux machines, so I took the executable file which is generated in the build folder of the project and executed it on the other linux machine. When I did that 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 developed the application using QT 5.3 but the linux machine where I am trying to execute it has libqt4 libraries. Is there any way for this file to be executable using the libqt4 libraries only.The following is my .pro file of the project:
#-------------------------------------------------
#
# 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 make changes in the "greaterThan(QT_MAJOR_VERSION, 4): QT += widgets" so that it works for qt4 libraries. I did that but it did not work. So could you let me know what could be done so that the project which is built using libqt5 can also be executed on machines which have libqt4. Installing libqt5 libraries can be done but I am looking for a way other than that.
Is there any way for this file to be executable using the libqt4 libraries only
Not easily at least... Even if you created symlinks, Qt 4 and Qt 5 are not binary compatible.
If you want to make it self-contained:
bundle the libraries statically.
Use dynamic symbol loading and based on the version you find, you may need to program the code to act differently. But it may be a hell lot of work.
hey make sure libqt5widgets are installed on your system and you are using the correct qmake (version 5x in your case) you can installl them on debian based distro by issuing the command or via Synaptic package manager
sudo apt-get install libqt5widgets5
Related
I am trying to port a Qt5.9 project from Mac to Windows 10.
I was able to compile the project easily in a ubuntu installation.
While trying to build it for windows, i had problems with finding zlib include headers with
#include<zlib.h>
That i corrected after following answers here on Stack to
#include<QtZlib/zlib.h>
Now i have problems in LINK phase, it can not open the file z.lib
Problem is i downloaded zlib packages, builds, source code and could not find a z.lib. Only different named libs. Searching in google i could only find people with the same problem, z.lib is not one of the libs included in zlib installation.
This is my project file:
TEMPLATE = app
QT += qml quick widgets websockets
CONFIG += c++11
SOURCES += \
main.cpp \
api.cpp \
app.cpp
HEADERS += \
api.hpp \
app.hpp
RESOURCES += qml.qrc
LIBS += -lz
I tried putting all possible dll and lib files in the project folder. None of them is named z.lib though.
The symbols for zlib are already part of the qt libraries. As long as you do not try to link the zlib explicitly it should work. At least it does work for me.
add to your project file:
!win32 {
LIBS += -lz
}
I managed to solve my problem updating my Qt installation to use MinGw 5.3 32bit. I was using VisualStudio 2015 as the compiler before.
Only changing the compiler to MinGw (g++) 5.3 made everything work with the same pro file i posted in the original question. Thanks everybody who tried to help!
I have successfully cloned git repository of QCA and built it using
cmake .
make
sudo make install
This created bin directory with some executables and I can confirm everything works as should by running
$ bin/qcatool-qt5 plugins
/usr/lib/x86_64-linux-gnu/qt5/plugins
/home/metheuser/qtcreator/qca/bin
Available Providers:
qca-gnupg
qca-logger
qca-ossl
This product includes cryptographic software written by Eric Young
(eay#cryptsoft.com)
qca-softstore
However when I specify in my Qt project:
QT += crypto
I get this error
Unknown module(s) in QT: crypto
I have no idea how to include the library now. I have tried adding this to my .pro file:
LIBS += -lqca
and
LIBS += -lqca2
Both resulting in error:
cannot find -lqca
What should I do? I followed the official README/INSTALL instructions.
you need to add the lib path to your .pro file. So, Instead of
LIBS += -lqca
you need
LIBS += -L$${PATH_QCA_LIB} -lqca
My .pro file looks like this:
QT += core gui widgets
SOURCES += a.cpp
HEADERS += a.h
FORMS += a.ui
#Locally compiled Qt framework. Qt/out/{QtCore.framework,QtNetwork.framework..}
QMAKE_LFLAGS += -L./Qt/lib/
QMAKE_CXXFLAGS += -F./Qt/lib/
macx {
QMAKE_MAC_SDK = macosx10.9
LIBS += -framework QtCore -framework QtNetwork -framework QtGui -framework QtWidgets
}
I want to use frameworks compiled locally, but QT5.5 automatically includes framework from QT5.5.0 install directory ... I see a.cpp compiling with following include switch:
-I/Users/banana/Qt5.5.0/5.5/clang_64/lib/QtWidgets.framework/Headers
I tried resetting INCLUDEPATH = in .pro file in hopes that it resets the default include path and added proper INCLUDEPATH += ./Qt/lib but it doesn't work.
Using MAC, OS X 10.10.2
The Qt installation that gets used will be determined by which qmake you run. If you have multiple versions of Qt installed (e.g. one you built from sources yourself and one provided by the system or by a Qt Creator install), you need to ensure you are running the qmake from the Qt you want to use. You should be able to verify this from the command line fairly easily. If you are using an IDE like Qt Creator and are having issues getting the right Qt selected, try building from a command line first to verify that you can get the right Qt that way as a first step. If building things from the command line where you have absolute control over which qmake is used still doesn't work, then this would suggest the qmake you are trying to use isn't behaving in the expected way.
I have a Qt 5.5 dynamically linked installed with MingW 4.9.2 32-bit and Qt Creator 3.4.2. In my build tree I created a helper console non-Qt app that has literally 20 lines of code and does not rely on Qt (only uses qmake so I do not have to install cmake). I would like that app to be built statically but no option I set in the build make arguments seems to be accepted (static, static-libgcc etc.). Is it even possible or do I have to build it separately outside of Qt(Creator) and possibly get cmake instead of qmake?
If you wish to link the executable statically to the C++ runtime, then the static_runtime feature does it. You'll also want not to link with Qt:
# .pro file
CONFIG -= qt
CONFIG += static_runtime
The static_runtime.prf file is only available in Qt 5/6. It's not present in Qt 4. For Qt 4, you have to do it manually:
QMAKE_LFAGS += -static
I'm trying to install libusb (not libusb-win32) on windows 7. I have to link it with Qt 5.0.1. Here are the problems I'm facing
In the INSTALL file in the extracted libusb folder, it tells me to cd to the current folder then run
./configure
make
makeinstall
But I got the error
'./configure' is not recognized as a valid command.
Googling this problem usually gives the solution as installing libusb-win32. However, I want to avoid that, as of now.
In the libusb library, there were a few MSVC projects, so I built them. That did generated some .lib files. So I proceeded to link them with my Qt project. It recognizes the libusb.h header file but does not link properly. Here is my .pro file
QT += core gui widgets
TARGET = Qt_libusb TEMPLATE = app
SOURCES += main.cpp\
qt_libusb.cpp
HEADERS += qt_libusb.h
FORMS += qt_libusb.ui
LIBS += -LC:\libusb-1.0.18\Win32\Debug\lib\libusb-1.0
INCLUDEPATH += C:/libusb-1.0.18/libusb DEPENDPATH += C:/libusb-1.0.18/libusb
My objective is to link the libusb library with Qt. Please tell me if I haven't 'installed' the library correctly or if I am linking it in a wrong way. thanks
Your project file does not reference the library. You only provide a path where libraries might be found, but there's no reference to the libusb library itself.
What you're missing is something like
LIBS += -llibusb
You also can't have multiple project file statements on the same line. The below is an error:
TARGET = Qt_libusb TEMPLATE = app
It should look like:
TARGET = Qt_libusb
TEMPLATE = app