How to run qmake from the static Qt - c++

For making a very simple Qt app "installable" on other systems, I'm using Qt Installer Framework following this link.
In bottom, in Setting up Qt Installer Framework, number 1 orders to have Qt Installer Framework source code. I downloaded it from here. (qt-installer-framework-opensource-2.0.1-src.zip)
Now I don't understand the next instruction there :(
It says:
2- Build the tools by running the "qmake" from the static Qt, followed by "make" or "nmake".
My question is, first what does it mean?
And from what path?
I don't know how to do it:(

qmake comes with the qt-framework and is a make file generator. (an alternative to cmake).
You call qmake on a .pro file from your project. This .pro file have to contain your source code files project dependencies and more.
Consider that you have a project folder with your source code and the .pro file. Then you call the qmake command in this folder. qmake is an program itself, which you can find in the bin folder of your qt-installation. If qmake is in your path variable, you go to the terminal, navigate to the specific folder and just write:
qmake
After that qmake will create a makefile. Then you could call makeand your program will be build.
I hope my answer helps you. You can learn more about qmake on the website of Qt. Here is also a very good qmake tutorial: klick
edit:
how to call make on windows:
download and install cygwin from
http://www.cygwin.com/setup-x86.exe - 32 bit installer or
http://www.cygwin.com/setup-x86_64.exe - 64 bit installer.
then start the Cygwin terminal (Cygwin.bat) and navigate to your folder and call
make
and that will build your qt-installer!

Related

Qt: .pro file missing?

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.

How to build a project under the src directory of Qt?

I found a .pro file 5.12.1\Src\qtbase\src\plugins\platforms\windows\windows.pro and opened it in Qt Creator. After configuring a MingW kit, I tried to build the project. But I got this error;
error: vulkan/vulkan.h: No such file or directory
#include <vulkan/vulkan.h>
Do I need to configure something before building the project? I do not want the vulkan support, just want to compile it successfully. I remember if I build the whole Qt src, I need to run a command like "configure xxxxx" in the src directory. Now I do not want to build whole Qt, just this project. There is a line in windows.pro that seems related to this problem.
qtConfig(vulkan): QT += vulkan_support-private
How should I do to remove the need for the vulkan stuff in order to build it successfully?
Yes, you will need to configure things. I suggest you read up on Building Qt 5 from source to understand what is involved.

How to add a Scintilla component to a Qt Creator C++ project?

I would like to use scintilla on a Qt project, but I don't know how to start, do I have to include the source files? or is there some library that I can reference?
The only installation examples I have found are for PyQt but I'm using c++ on Linux.
QScintilla is a library derived from Scintilla to use with Qt. This library can be downloaded from https://riverbankcomputing.com/software/qscintilla/download.
To use this library you need to build and install first. As you use Linux, the building process is
cd Qt4Qt5
qmake
make
make install
Note:
The directory Qt4Qt5 is inside the uncompressed QScintilla directory.
Make sure Qt binary path is in your Linux PATH variable.
To use QScintilla in your project, in your .pro file just add the following line.
CONFIG += qscintilla2
The library comes with an example. To build the example use the following commands in your bash.
cd example-Qt4Qt5
qmake
make

How to create executable file for a Qt Application?

I've been searching on the internet for some useful and clear information about this, it's annoying that such a trivial thing is so hard to do.
What I need is to create an executable file for my Qt project, in order to run it in other computers. My project runs nicely in the Qt Creator, but when I try to run the executable created in the release folder I get errors about some dll missing, and though I have put all of them in the same directory of my .exe I now got some errors about entrypoints in procedures inside the dll (QtCore4.dll).
The solution looks like to be a static linking, I've found many information about it, but none of them really helped me. Here is what I have tried so far:
Using the executable created in the release folder as I said above.
Static Linking, following this tutorial (and many others, all almost the same thing): http://doc.qt.io/qt-4.8/deployment-windows.html but I get the following error during the "configure -static": NMAKE : fatal error U1077: '"c:\Arquivos de programas\Microsoft Visual Studio 9.
0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
Building qmake failed, return code 2
For that I couldn't find any solution, so here I am, just trying to create an executable file for my Qt project, hope you guys can give me some light here.
Basically you have to look for mingw subfolder deep into qt tree, where qt utilities reside, and copy needed dll's.
These are the steps I follow, based upon QT 4.7.4, for packaging the application with correct shared libraries.
Let's say you've installed QT under c:\qtsdk
Open your project, and compile it in release mode.
Go to this directory: C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin -- it contains all shared libraries. Debug libraries end with a "d" -- frex, QtCore.dll is release version, while QtCoreD.dll is debug version
Copy at least these files into your release directory (where your .exe lies)
mingwm10.dll
libgcc_s_dw2-1.dll
QtCore4.dll
QtGui4.dll
I just built, tested and deployed a dummy project this way.
Do these steps:
1- Open qt command-line window.
2- Go to the directory which .exe file exists (using cd command).
3- Run windeployqt.exe --quick . command
4- Run your exe file and enjoy it!
This video is great
Here is what I did and I got it to work after some time;after making sure that your program builds inside Qtcreator,go to the directory that contains your exe and double click on it.(I'm using windows and don't know if it is the same on other platforms).A window should popup telling you which .dll is missing.Go to the directory where Qt is installed and type the exact name in the search bar(top-right in Windows 7) and the dll should show up in search results.Right click and choose open file location.Copy the file where your exe is located .Double click on the exe again.If another .dll is missing repeat the same thing until none is missing.In the end your program should run.
Hope this helps.
So you downloaded Qt SDK and you want to link Qt libraries statically into you application, right?
First of all, if you link statically, you don't need any Qt*.dll to be present anywhere because it is built into the application. So that alone means that your application is built using dynamic linking.
From my experience, that safest way to get it all working is:
Download Qt sources, build and install them with nmake ( using Visual Studio Command Prompt from Menu Start -> Application -> Visual Studio 2008 ). Just remember that the size of the statically linked application is dependent on the size of the *.libs and these are dependent on the pre-build configuration, for example, you can minimize the size of you application by turning off some features ( this is an example config for MacOSX, just watch out for the ones specific for Windows and add proper plaftorm - see configure.exe --help for details ):
./configure -arch x86 -platform macx-g++ --universal -cocoa -debug-and-release -opensource -static -fast -no-accessibility -no-sql-sqlite -no-qt3support -no-opengl -no-openvg -qt-zlib -no-gif -no-libmng -qt-libmng -no-libtiff -qt-libjpeg -no-3dnow -sse -no-sse2 -no-openssl -no-dbus -no-phonon -no-multimedia -no-audio-backend -webkit -no-script -no-scripttools -no-declarative -nomake demos -nomake examples -no-exceptions -no-accessibility -confirm-license
Install, setup and use Visual Studio Add-In for you Qt project (here ).
Good Luck! :)
I share with you my solution. On my qt creator 4.2.1, I did these steps:
1) - I clicked on release and it generated a folder in my project directory like that: C:\Users\Samir\Documents\Qt-Projects\build-Calculator-Desktop_Qt_5_8_0_MinGW_32bit-Release.
2) - I opened the terminal qt 5.8 for desktop and I navigated to my project directory where the .exe located.
3) - Finally, I ran the command line windeployqt.exe --quick .. This command allowed me to generate the libraries which were missing.
And now everything works fine!

Qt C++ Stand alone executable in Windows

I want to make my Qt C++ program a stand alone single application. By the way, I am using Qt creator 2.2.1 which is based on Qt 4.7.4. I followed the instructions from http://www.formortals.com/how-to-statically-link-qt-4/ to statically link the libraries. I did not know where to find the configure.exe in the QtSDK folder so I downloaded "qt-everywhere-opensource-src-4.7.3" and followed the instructions.
I was unsure in Step 4 because the windows Qt options do not look similar. Its not a path to a folder but rather a path to qmake location and I am not sure what to choose for that option.
If anyone knows how to create the program as a stand alone without needing any dlls and can help me out, I would really appreciate it.
Thanks
Regarding the step 4 you mentioned, in QtCreator you need to point the qmake executable you will find it in the build tree (where you built Qt statically) in the bin folder.
I guess if you have problems on step 4 you should have built the static version of Qt, you've done 95% of the work !
The moment QtCreator will accept the qmake you made, you will just have to select this version use any wizard to get you first app, then add CONFIG += static to you .pro file.
Here some Qt tutorial just in case.