qmake build from command prompt - qt

I need to have a cmd build script to address x86 x64 compilation issue associated with the IDE (i mean switching qt versions & rebuilding). The problem is that, in my .pro file, I add dependency on external library in this way:
LIBS += ../Libs/SomeExternal.lib
Now when I build this project from QtCreator, everything compiles and builds fine, but when I try to build using command prompt + qmake I get the following linker error:
LINK : fatal error LNK1104: cannot open file '../Libs/SomeExternal.lib'
I understand that this issue is related to paths, but I don't know how to let LINKER.exe see the location where my project is located. Just like QtCreator does.
I try to build using the following way:
I run VS command prompt. I'm using MSVC compiler.
I type qmake.exe -project C:\ProjectPath\Project.pro
nmake
Thanks

Use:
LIBS += -L$${PWD}/../Libs -lSomeExternal
From the documentation:
The PWD variable specifies the full path leading to the directory
containing the current file being parsed.

Related

The code executable cannot continue: libgcc_s_seh-1.dll was not found

I have a problem that I cannot solve, When I run the executable of my program it gives me the following error:
The code executable cannot continue because libgcc_s_seh-1.dll was not found. To fix the problem, try reinstalling the program
I tried to manually copy and paste the file (libgcc_s_seh-1.dll) into the folder where I keep the executable but I get the following error:
The application could not be started correctly (0xc000007b)
Additional information:
I use windows 10 64 bit
I Use mingw81_64
I use version 6.1.2 of Qt
What can I solve the problem?
I guess you double-clicked in exe file that provides after building in release mode :
For Deploy and create Exe output with QT in windows you should follow this way:
put your compiler path in your system path. now you use mingw81_64 you should set it. something like Qt/tools/mingw81_64/bin
copy exe file that provides after building in release mode in one folder and run mingw81_64 cmd (it has separate cmd)
and cd to that folder path
windeployqt app.exe
This command will get all dll needs for your app and your exe will work .
if you use qml
windeployqt --qmldir (the path of its directory ) app.exe
and also see these youtube videos for more info:
https://www.youtube.com/watch?v=LdSTgR0xJco
https://www.youtube.com/watch?v=hCXAgB6y8eA
For specific error of libgcc_s_seh-1.dll was not found, please try to copy libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll into your compiler path like Qt/tools/mingw81_64/bin.
You should copy libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll into your exefile path after executing windeployqt.exe with all files are in correct version.

Qt running error "Executable does not exist"

I installed Qt version 5 on Mac OSX and tried to build a simple project found on a book.
The project at first compiled and run correctly then I tried to do Clean all and Build all. At this point it seems to compile correctly, but when I try to run it, I am getting the following error:
Executable /Users/myMac/build-project_name-Desktop_Qt_5_5_1_clang_64bit-Debug/project_name.app/Contents/MacOS/project_name does not exist
Notice that the project folder is /Users/myMac/project_name
I had also to modify the file *.pro by adding QT += widgets because I got also the TARGET is empty error.
I tried to look for older questions but I did not find anything useful. Does anyone have any suggestion?
Here is my .pro file:
######################################################################
# Automatically generated by qmake (2.01a) Sun Mar 20 21:45:06 2016
######################################################################
QT += widgets
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += finddialog.h mainwindow.h
FORMS += mainwindow.ui
SOURCES += finddialog.cpp main.cpp mainwindow.cpp`
I needed to exit and restart QtCreator to fix a similar issue, although my error is slightly different from the OP's.
I am using CMakeLists.txt projects in QtCreator and we have a complicated cross-platform set of hundreds of projects.
Here is what led to my problem and I just reproduced it in Qt Creator 4.4.0 to verify the steps:
I added a new, command-line utility project in a subdirectory (i.e. add_subdirectory in CMake) by copying another similar project - I forgot to change the name
I ran CMake and it failed because the name was defined previously
I corrected the name of the new project (to 'a_exp')
I reran CMake successfully and QtCreator located the new project, a_exp
I used QtCreator to build the executable, a_exp
I confirmed in the shell that I could run the executable, a_exp
When I attempted to run in QtCreator, I got an error like the OP
Here is the error:
Starting a_exp...
Executable a_exp does not exist.

How to modify the PATH variable in Qt Creator's project file (.pro)

I use Qt Creator 3.4.2 for Windows and MSVC2013 compiler. When I build the project I get an error:
LNK1158: cannot run 'rc.exe'
I managed to fix it by adding
"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Bin"
to the PATH variable under
Projects -> Build Environment
But I need to modify the PATH variable by editing the .pro file. This would make it easier to open and build my project on another computer because all the paths would be stored in the .pro file. This solution does not work:
PATH += "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Bin"
Is it possible at all?
It is strange that you have such error, since Qt Creator should detect MSVC compilers and build project in appropriate environment. Qt Creator knows that it should run required batch file to prepare environment of VS Command Prompt console, for example C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat x86
Anyway, it is possible to write qmake project file (.pro) that creates Makefiles that run any custom shell command before actual project compilation.
When qmake processes .pro file it only creates Makefiles. Then the compilation is done by other make build tool. Qt Creator uses its jom make utility. From VS console it is possible to run nmake.
Make utility runs different tools according to specified in Makefiles rules. It is possible to create additional phony target with build command that sets PATH variable. The main target should depend on this target.
The following lines in .pro file create such rules:
QMAKE_EXTRA_TARGETS += customtarget1
customtarget1.target = dummy
customtarget1.commands = set PATH=C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Bin;$(PATH)
PRE_TARGETDEPS += dummy
So, during processing Makefiles the first target is dummy. Its "build" command sets PATH. Then all other tools run in that environment.

How To Compile QFtp Example in Qt 5?

I have application which uses QFtp class.I have made in Qt 4 version.
But now i want to complie QFtp classe in Qt5 but it's showing some error like:
'QFtp' doesn't name and type.
how to resolve this issue. I don't want to use QNetworkAccessManager. is there any way to this?
Thank you
For the sake of completeness, the steps to use the add-ons are:
Download the sources for the add-on from https://github.com/qt/qtftp
Extract the sources somewhere (e.g. Qt5.x.y/Src/qtmyaddon)
Open a console in that folder
Read readme.txt and run the appropriate commands with the latest QT version
Run qmake
Run make (or nmake or mingw32-make or whatever)
Run sudo make install (nmake install, mingw32-make install, ...)
In the .pro file of your project, add "QT += myaddon" (e.g. "QT += ftp")
Run qmake on your project
Compile your project

Qt creator: qmake is not recognized

I am trying to understand 'qmake' by following this tutorial . but when I come the the following command:
qmake -o Makefile hello.pro
my command line console shows me this message:
'qmake' is not recognized as an internal or external command, operable program or batch file
I understood that qmake is part of Qt creator and thus it should be executed whenever I run it within my project's folder. so, why it is not recognized ?
In the start menu entry that was created by the installer for Qt, you should find an item that opens a command prompt with all the needed environment variables (including the PATH) already set. For my Qt 5.0.2 install using MingW, it is called "Qt 5.0.2 for Desktop (MinGW 4.7)".
On Windows, you can add path to qmake to PATH or run qmake from directory where it placed, or use absolute path.
Sorry my friend, i donĀ“t speak English very well.
In Qt 5.10.1 I resolved this problem running the command prompt in the next path, C:\Qt\5.10.1\mingw53_32>, after you need change the directory where is the file hello.pro and run the commnand qmake -o Makefile hello.pro after you can see the makefile in the respective folder.

Resources