Two identical Qt5 projects with different names. One handles the ReadyRead QtSerialPort the other is not. What could be the reason?
The build folder itself was deleted does not help (with the transfer of a troubled project to a different folder is working fine).
Windows7x86 mingw32 Qt5.12.5
In github.com
rm CMakeLists.txt.user*
And deleted all build folders, including those not related to the project. QtCreator sometimes mixes the build folder paths with other projects.
Related
I tried to create a C++ project with Qt I stumbled across different kinds of guides which all refer to a special '.pro' file inside the project where I have to adjust a setting so the SQL part takes effect.
My problem: whenever I create a new project - doesn't matter whether its with qbs, qmake, or cmake - the project structure/ folder is lacking the '.pro' file.
Currently I'm using Qt 5.15.2 (via QT Creator) with MinGW Kit and cmake/ qbs.
As I'd like to play around with SQL-based apps.
Maybe I'm just skipping/ overlook something?
TL;DR: Use cmake. Forget about qbs and qmake.
Whenever I create a new project - doesn't matter whether its with qbs, qmake, or cmake - the project structure/ folder is lacking the '.pro' file.
A qmake project will have the .pro file, since that's the project file for qmake. Maybe you're looking in a wrong place? A qbs project will have a .qbs file, since that's what qbs uses. A cmake project will have CMakeLists.txt, since that's what cmake uses. It all works for me.
I'm just confused by all these guides stating that I have to add QT += widgets sql in the .pro file.
Those guides only apply when you use qmake, since .pro are qmake project files.
I suggest that you use cmake, as qbs is abandoned now, and there's no benefit to using Qt-specific qmake over the widely supported and continuously developed cmake.
Qt documentation covers the basics of how to use cmake to build Qt projects.
Qt support is provided natively by cmake, and it thus provides a comprehensive reference page.
What are the necessary dll files to deploy an application using Qt? By necessary I mean those who are common to all applications, not the entire dll folder. Are msvr120.dll and msvc120.dll necessary too? Thanks to further answers.
Dependency Walker is your best friend in this case.
In short, it depends on how many Qt modules you used in your project.
Check your project file, for example:
QT += core gui script
Then you will need
QtCore4.dll / Qt5Core.dll (QtCored4.dll / Qt5Cored.dll for debug)
QtGui4.dll / Qt5Gui.dll
QtScript4.dll / Qt5Script.dll
which can be found in bin folder under Qt directory.
As for msvr120.dll and msvc120.dll. You may distribute them as well, in case your user's Windows system doesn't have them (e.g. older version like Windows XP, but I am not sure whether those dlls work in older version of Windows)
Windows Qt installations include windeployqt.exe deployment helper which will copy Qt(and MinGW if you use it) library .dlls. Check your Qt installation directory, it's in same as qmake.exe
Basic usage from cmd: (Replace --debug with --release for release builds)
mkdir Deploy
copy /y /path/to/exe Deploy
cd Deploy
windeployqt.exe --debug Prog.exe
Aside from required .dll files it will also put optional plugins, translation files and configuration files for everything. You can later remove non needed files and upx the rest.
Additional info here: Qt for Windows - Deployment (thanks peppe for link). windeployqt.exe is mentioned at the bottom of the page.
Note: It can't deploy MSVC runtime libraries. You need a redistrubutable for them, so you can silently install them with your installer.
I've copied all of the dlls from QT that were required, and my application works fine on my Windows server machine.
However when trying to run it on a Windows 7 box i get the following message:
This application failed to start because it could not find or load he
Qt platform plugin "windows".
Reinstallning the application may fix this problem.
Any ideas what I'm missing here?
I'd scratched my head over this some time ago. It turned out that this was caused not by missing qwindows.dll, but rather one of libEGL.dll or libGLESv2.dll. This was tricky, because dependency walker does not show those libs as direct dependencies.
If you want to test on your dev machine, whether your app has all required libs, fire up console issue SET PATH=, cd to your app directory and run it.
This is complete list of dlls that my app is using (Qt 5.2 / QtQuick app only, rest is C++). QtQuick is nice but the size of Qt dependencies is a bit scary:
icu*.dll - depending on whether you've compiled with ICU
libEGL.dll
libGLESv2.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Network.dll
Qt5Qml.dll
Qt5Quick.dll
Qt5Widgets.dll
Widely used solution is put all necessary libraris in the folder of application.
What are libraries application need?
Run application and see error message:
The program can't start because <Library name> is missing from your computer.
Try reinstalling the program to fix this problem
Library set is depended from Qt version. Run several times application and each time copy required lib you found what is neeeded for application.
In my case (Qt 5.2.1) there are
icudt51.dll,
icuin51.dll,
icuuc51.dll,
libgcc_s_dw2-1.dll,
libstdc++-6.dll,
libwinpthread-1.dll,
Qt5Core.dll,
Qt5Gui.dll,
Qt5Widgets.dll.
All libs you can found in your Qt install folder. But don't use libraries from Tools\QtCreator folder, because QtCreator has another version of these libraries!
In case of error:
This application failed to start because it could not find or load he Qt platform plugin windows. Reinstallning the application may fix this problem.
You should create folder platforms and copy qwindows.dll into it.
If you still got error you should create qt.conf file in application's folder with content:
[Paths]
Plugins=plugins
This solution is described in https://qt-project.org/forums/viewthread/37265
More information about qt.conf you can find at http://qt-project.org/doc/qt-5/qt-conf.html
In latest versions of Qt you can find deploy tool (since 5.2). This tool find necessary libraries for application and copy into application folder. You can run it something like this:
call c:\Qt\QtX.Y.Z\X.Y.Z\mingw48_32\bin\qtenv2.bat
cd /d "c:\path\to\your\application\folder"
windeployqt.exe your_application.exe
Generally it works well. But I notice that some libraries are not copied, but you can found by method is descibed at beggining of post. More useful information you can find at
http://qt-project.org/doc/qt-5/windows-deployment.html
In rare cases yo can got this error if some library is missing but not appear in error message above. Example: Qt 5.1.1: Application failed to start because platform plugin "windows" is missing
I wasn't in this situation, so I can't tell more.
I'm looking for generating a redistributable project for Windows and Linux using CMake as project configuration system and gcc-4.8 / VS2012, plus extra thirdparty libraries like Qt5. How can i create a package with all the needed dependencies and make the project running on other machines, without installing on those machines the required packages (i.e. Qt5 setup)?
EDIT
Googling heavily i've found Qt5 requires some files and i've found this discussion
Application deployed with QT5 libraries does not start on Windows 7
which explains the required Qt5 dependencies.
Normally, I would use install to list the desired files and CPack for packaging them. That is, suppose I'd like to create a package consisting of the following components:
my_nifty_library.dll
my_nifty_executable.exe
QtCore.dll
QtGUI.dll
(Disclaimer: I'm not Qt expert so the last two files might not exist at all, but you get the idea.)
Given that both my_nifty_library and my_nifty_executable are part of your project, you have control over them, so simply do the following:
install(TARGETS my_nifty_library my_nifty_executable
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
Now, since Qt won't be built as part of your project, I suggest you use the ExternalProject module.
Now, you can use CPack and create, say, a NSIS installer or a tar.gz out of the installed files.
Does it make sense to add relevant Qt Libs and headers (opensource version) to a projects repository or should I just reference them from the sdk directory ?
I (alone) am developing a cross-platform (windows/linux) c++ application which, will be using a number of thirdparty opensource libraries including Qt, OpenCV, log4cpp to name a few.
I started off development in Qt Creator for convenience (speedy GUI creation). Currently I have the Qt Sdk installed on both Linux and Windows outside the project directory.
I'm planning to move to CMAKE to for better configurability, e.g out-of-source builds and independance from Qt Creator and I would like to have all dependencies included in the project directory structure -so that I or anyone else can checkout the project and build without needing to install any other dependancies.
I have added all libs but Qt's to the directory as I am a little unsure weather its worth it -it seems like CMAKE depends on the Qt Sdk for compiling Qt specific files i.e moc, ui etc... (see here) is this the case ? or is there a better suited build tool ? (Originally I was I going to use Scons but I decided not to as the there seemed to be limited support.. and there hasn't been developement on Qt4 Tools since 2010, which doesnt inspire confidence either.)
Qt is too big to be put in a project directory, even if you include only one of its modules. Also you have some convenient functions in CMake to use Qt (add moc, rcc, ui). You can even write these functions by yourself (in fast, they just add a pre-build command).
For the build operations: you will need to use the moc (and maybe ui, rcc, ...), which is not provided by CMake. So, a person wanting to build your application must have the Qt SDK installed. Luckily, this installation is very easy.