Build program with QT 5.0.2 on Windows - qt

I want to build my program(developed with QT 5.0.2) and give it to some friends.
How can I process?
I tried qmake -project and qmake in my folder with the *.cpp files, but it didn't create any exe.
This is my .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2013-08-03T18:53:41
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = target
TEMPLATE = app
SOURCES += main.cpp\
class1.cpp\
class2.cpp\
class3.cpp\
class4.cpp
HEADERS += class1.h\
class2.h\
class3.h\
class4.h
FORMS += class1.ui\
class3.ui

Have you compiled your QtSDK statically? if yes, you can build your project as static linking, either you can't, if your are manually download your Qt repository from qt-project.org, it is a shared version of Qt, you should remove the line contain CONFIG += static and compile your project as shared and add the line below to your .pro file:
QT += core gui
Note:
Use Qt Creator as Qt Framework IDE to manage and build your projects, it's really handy and great tool, another way is use Visual Studio Add-In that integrates with VStudio, if you are professional in Qt architecture, you can use makefile base building of Qt withqmake.

Tutorial for building project on Windows

Related

Qt Quick Designer Components module Static Linking not working

I'm trying to cross compile Qt Quick Designer Components to get QtQuick.Studio.Effects module on Qt 6.5 on arm64 target as I'm getting "module 'QtQuick.Studio.Effects' is not installed" when I try to to run my cross compiled qt application.
So far I have cross compiled Qt Quick Designer Components with help of this and it outputs libQuickStudioEffects.a static library. I tried to link it in .Pro file by adding the library with qt creator which generated following lines.
unix:!macx: LIBS += -L/home/user/qt/ -lQuickStudioEffects
INCLUDEPATH += /home/user/qt/
DEPENDPATH += /home/user/qt/
unix:!macx: PRE_TARGETDEPS += /home/user/qt/libQuickStudioEffects.a
lib file and executable both are in /home/user/qt/ location in target and host pc.
also I tried with following line.
LIBS += /home/user/qt/libQuickStudioEffects.a
So far executable is not detecting the lib file and giving me the above mentioned error. I can run other cross compiled qt6 programs on my target device without any issue. My host runs Ubuntu 20 and target runs on debian 11. Any help is really appreciated. Thanks.
Build the dev branch from here and it will give the dynamic QtQuick.Studio.Effects library which can be cross compiled.

Cannot find .pro file in Qt Creator

I'm new to Qt, learning through a Qt Creator tutorial. I am trying to connect Qt with a MySQL database. To do so, I have to modify a .pro file adding the command QT += core sql
However, once I create a project there is no .pro file in the menu, only the .ccp file.
Program installed: Qt Creator 4.13.0
OS: Windows 10 x64
Steps followed:
Choose New Project
Choose Qt Console Application
Build system: CMake
Kits: I have some available; I am using Qt 5.15.1 MSVC2019 64bit
The menu displayed shows a CMakesList.txt file, and the main.ccp source file. However no .pro file is created.
For new build system you should modify CMakeList.txt file.
Please try to replace
target_link_libraries(myapp Qt5::Gui)
with
target_link_libraries(myapp Qt5::Gui Qt5::Sql)

QtCreator (2.8.0), using shared libraries

I developing a GUI app with Qt 5.1 and QtCreator 2.8.0 and I'm using a shared library (also compiled with Qt 5.1).
This is what I'm using in the .pro file:
INCLUDEPATH += ../MyLib
QMAKE_LIBDIR += ../MyLib/build/release
LIBS += -lMyLib
Regarding the "Run Configuration" (QtCreator) and under Linux (Ubuntu 12.04) I set the LD_LIBRARY_PATH to "(...)/MyLib/build/release" and it works well. However, on Windows, appending the library path (.dll) to PATH doesn't work. I don't get any compiling nor linking errors but when I run the app it immediately exits. If I put the .dll on the same folder as the executable it runs without any problem. Am I missing something?
Hard to say from the information you gave. Surely Windows does find the dll if you put its path into PATH. But maybe your dll uses another dll, which is not in the normal search path?
You might want to try the dependency walker: http://www.dependencywalker.com/
If your dll is based on Qt it might be that it does not find necessary qt plugins.
Check this out: http://qt-project.org/doc/qt-4.8/deployment-windows.html#application-dependencies
Qt 4, but Qt 5 is the same in this regard.

c++ Using PortAudio in Windows with Qt

I have managed to compile PortAudio on windows using MSYS.
this process has created 2 files: libportaudio-2.dll and libportaudio.dll.a
Now i want to link the libraries in QtCreator, but i can not since it requires a .lib file.
If anybody have experience of compiling and using libraries with MSYS under windows, your input is appreciated.
(Note: they are compiled using MindGW compiler. I dont want to compile it with Microsoft Visual Studio, since then i will have to compile QT)
to solve your problem is very simple. Here I report an example of a file. pros who need to use:
QT += core
QT -= gui
TARGET = mioTestAudio
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
LIBS += -lportaudio.dll <-------- this is the part you are interested
SOURCES += main.cpp

Libqxt under Qt Creator

I want to create a tiny app which needs global shortcuts. So, I have downloaded the current version of libqxt (0.5.1) and opened as a project in Qt Creator.
Libqxt compiles without problems in this way, so I thought that adding this in the tab Dependencies of my project it would get added automatically in the build, like Eclipse does with JAR libraries (I know that are different IDEs but it seems to be a common feature among them).
What happens? Qt Creator compiles qxt before my project, when needed, but when I want to include its headers Qt Creator keeps warning me that it cannot find them.
Probably I am missing the correct name of headers (I tried the headers showed in qxt documentation: http://doc.libqxt.org/0.5.0/classQxtGlobalShortcut.html)
By the way, I looked the code for global shortcuts and I think I can rip it out and use it in my app as is and I am going to credit qxt team and open the code of my app.
from the documentation
Add the following lines to your .pro file:
CONFIG += qxt
QXT += core gui
Note: While building the Qxt on Linux do not forget to do a sudo make install otherwise this little piece of magic may fail to work.
Qt Creator doesn't know how to expose different libraries to your projects. It's developer's duty. Dependency ensures only that mentioned projects are already built before building your main project.
Your real concern was using Qxt without proper installation. Assuming that configure have been run and libqxt have been built (using Qt Creator or manually via qmake+make), my solution is adding following snippet (with obvious QXT_DIR customization) to .pro file:
QXT_DIR = $${IN_PWD}/../libqxt-0.5.1
LIBS += -L$${QXT_DIR}/deploy/libs
INCLUDEPATH += $${QXT_DIR}/deploy/include
for(module, QXT) {
MODNAME = $$upper($$replace(module, "(.).*", "\1"))$$replace(module, "^.", "")
INCLUDEPATH += $${QXT_DIR}/deploy/include/Qxt$${MODNAME}
INCLUDEPATH += $${QXT_DIR}/src/$${module}
win32:CONFIG(debug, debug|release):MODNAME = $$join(MODNAME,,,d)
LIBS += -lQxt$${MODNAME}
}
Unfortunately I'm not sure whether it works in complex projects.
By default Qxt is built in release mode, but Qt Creator uses debug mode and it leads to broken binaries of projects depending on Qxt under Windows. You have to switch your project to release mode or build Qxt in debug mode (run configure -debug and rebuild Qxt).
Last thing: In Windows you won't be able to run your project from Qt Creator even if you successfully build it. You must copy needed Qwt*.dll files (use the d-suffix versions if you're in debug mode) from libqxt-0.5.1/deploy/libs to your_project/(release|debug) directory .

Resources