I have a qt .pro file which looks something like this:
TEMPLATE = app
TARGET = demoqt
DESTDIR = ./debug
QT += core gui
CONFIG += debug
DEFINES += QT_LARGEFILE_SUPPORT QT_DLL
HEADERS += ./src/MainWindow.h
SOURCES += ./src/MainWindow.cpp ./src/main.cpp
Its building successfully under windows with the following .bat:
#echo off
echo Setting up a Qt environment...
set QTDIR=C:\Qt\4.8.3
set PATH=C:\Qt\4.8.3\bin;%PATH%
set QMAKESPEC=win32-msvc2010
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64
qmake
nmake
I have absolutely no experience with makefiles what so ever - I completely winged this. The problem I'm experiencing is that the necessary Qt DLL files are not getting copied to the output directory. As such, when I execute my executable file, I get errors such as The program can't start because QtGuid4.dll is missing from your computer. Try reinsalling the program to fix this problem.
I would just add a line in the .bat file at the end to copy QtGuid4.dll (and any others) to the output directory.
If it's a personal project and you're not worried about installation/distribution issues, you can just copy them once manually to the Windows system directory (actual name depends on os version).
Related
I made a QT GUI project in VS 2019. It ran perfectly through VS. Copied the entire project files directory to Linux partition. Ran qmake -project in the directory containing the 'test2.sln' file to create a 'test2.pro' file. Opened the '*.pro' file through QT Creator. It imported everything fine. But, when building it it errors out saying "ui_test2.h file not found".
The test2.pro contains:
TEMPLATE = app
TARGET = test2
INCLUDEPATH += .
DEFINES += QT_DEPRECATED_WARNINGS
HEADERS += test2/test2.h test2/x64/Release/uic/ui_test2.h
FORMS += test2/test2.ui
SOURCES += test2/main.cpp test2/test2.cpp test2/x64/Release/rcc/qrc_test2.cpp
RESOURCES += test2/test2.qrc
What should I do to fix this?
1) remove folder with build (rm -r nameOfFolder)
2) rename your UI file (test2.ui -> mainwindow.ui) for example
3) check out name of own class and name of qt class in UI file (you can open it via vim or nano)
After that try to rebuild your project!
I hope you'll have done this with good results!
I'm using Qt 5.5 for a project, and am trying to use the install feature to copy files into the build directory. I have in my .pro (this is a simplified version I am using to try and figure out the issue):
copy_files.path = $${OUT_PWD}/debug
copy_files.files = win32_libs/*
INSTALLS += copy_files
I have in the build configuration an extra step after "make" which is "Make install" for both debug and release (selected from the "Make" drop down item). After clean -> run qmake -> build, Qt absolutely refuses to copy any of the files in "win32_libs" into the debug build directory.
If I specify just "win32_libs" instead of "win32_libs/*", it will copy the directory (not helpful), and it turns out it will copy any directory, but no files unless they are CONTAINED in a directory (again, not helpful).
So how can I convince it to just copy the files?
After facing similar problem and no being able to solve it directly I decided to do the workaround for the Windows target like:
# post build copy dependencies
win32 {
# all the necessary files listed relative to the root project directory
OTHER_FILES += stuff\myfile1 stuff\myfile2
OTHER_FILES += stuff\myfile3 stuff\myfile4
DESTDIR_WIN = $$DESTDIR
DESTDIR_WIN ~= s,/,\\,g
# debug pro file statement
message(Destination WINDOWS $$DESTDIR_WIN)
PWD_WIN = $${PWD}
PWD_WIN ~= s,/,\\,g
for(FILE, OTHER_FILES){
QMAKE_POST_LINK += xcopy /d/y $${PWD_WIN}\\$${FILE} $${DESTDIR_WIN}$$escape_expand(\\n\\t)
}
}
And xcopy command provided with parameters to avoid actual unnecessary copy.
I am trying to write a Qt application that will use QProcess to call ffmpeg.exe to convert media files. I cannot figure out the best way to make sure that the ffmpeg.exe file gets copied from my development directory to the build directory so that the built (and later deployed) application will have access to it.
I have seen information about using the INSTALLS parameter in my .pro file (https://stackoverflow.com/a/13168287) but the qmake docs say:
Note that qmake will skip files that are executable.
with all of the above said, how should one go about making sure that the exe file I want to use for QProcess ends up in the build directory (ready to be deployed later)?
You can use QMAKE_POST_LINK to execute a copy command when the application is built. Just put this in your .pro file :
win32:{
file_pathes += "\"$$PWD/Path/To/Files/ffmpeg.exe\""
CONFIG(release, debug|release):{
destination_pathes += $$OUT_PWD/release/
destination_pathes += Path/To/Deploy/Directory
}
else:CONFIG(debug, debug|release):{
destination_pathes += $$OUT_PWD/debug/
}
for(file_path,file_pathes){
file_path ~= s,/,\\,g
for(dest_path,destination_pathes){
dest_path ~= s,/,\\,g
QMAKE_POST_LINK += $$quote(xcopy $${file_path} $${dest_path} /I /Y $$escape_expand(\n\t))
}
}
}
You should add the paths for the files that you want to be copied to file_pathes variable and the paths to the destination directories to destination_pathes variable. Then all files would be copied to all the destinations when the application is built.
Here ffmpeg.exe gets copied to application build and deploy directories in release mode and to build directory in debug mode.
After reorganizing my source files into subdirectories and directing output like
CONFIG( debug, debug|release ) {
DESTDIR = $$PWD/build/debug
} else {
DESTDIR = $$PWD/build/release
}
OBJECTS_DIR = $$DESTDIR/.obj
MOC_DIR = $$DESTDIR/.moc
RCC_DIR = $$DESTDIR/.qrc
UI_DIR = $$DESTDIR/.ui
it seems that a resource file included with
RC_FILE += res/projectname.rc
is not compiled into a corresponding .res file, as jom.exe quickly returns
C:\QtSDK\QtCreator\bin\jom.exe -f Makefile.Debug
Error: dependent '"c:\path\to\projectname\build\debug\.obj\projectname.res"' does not exist.
The file indeed does not exist.
If I manually run "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\RC.exe /r projectname.rc" and copy the resulting .res file to the folder specified in the Makefile.Debug in LIBS and RES_FILE and in one of the first build rules it works fine.
So the question is, why is the file not created anymore (it works with the old project with all source files in the project directory and default "release" and "debug" dirs).
Adding debug options to Qt Creator's Project>Build Settings for qmake (-Wall) and jom (VERBOSE=2) did not produce much more information about what goes wrong.
The Makefile.Debug has a target for the .res file, where the source file is without absolute path, but even when I complete the path it does not work.
How can I get more debug output from jom to see whether rc.exe is called at all?
Here is the output when it fails:
18:39:45: The process "c:\qtsdk\desktop\qt\4.8.1\msvc2010\bin\qmake.exe" exited normally.
18:39:45: Starting: "C:\QtSDK\QtCreator\bin\jom.exe" VERBOSE=2
C:\QtSDK\QtCreator\bin\jom.exe -f Makefile.Debug
Error: dependent '"c:\path\to\projectname\build\debug\.obj\projectname.res"' does not exist.
jom 1.0.8 - empower your cores
jom: c:\path\to\projectname\Makefile [debug] Error 2
18:39:46: The process "C:\QtSDK\QtCreator\bin\jom.exe" exited with code 2.
Error while building project projectname (target: Desktop)
When executing build step 'Make'
I have also added the SDK's path to the system variables. I am using VS C++ 2010 Express to compile.
Possible cause: Redefining the build directory apparently caused the tools to use the absolute path which contains spaces, resulting in a program call to fail (but which? rc.exe's`)
Solution: No further information about getting proper debugging output of the toolchain (jom and qmake), but making sure no spaces are in the path resolved the problem: the executable has its resource information embedded again..
I have been trying to use QCA (Link) on my Windows PC for a couple of days now, works fine on my linux box, just can't get it working with Windows.
So i followed all the instructions for installing QCA and then the ossl plugin for QCA. The QCA works fine but for some reason the plugin isn't showing up in my Qt Creator nor am I able to use some of the functions in the plugin.
I used the qcatool2.exe that comes with QCA to check my plugins using
qcatool2 plugins --debug
and get this error message:
plugin: qca-ossl2.dll: failed to load: The plugin 'C:/Qt/2010.05/qt/plugins/crypto/qca-ossl2.dll' uses incompatible Qt library. Expected build key "Windows mingw debug full-config", got "Windows mingw release full-config"
Now this seems to me as if qt requires the plugin to be compiled in debug mode (as to get the build key to contain debug rather than release) so I added
CONFIG += debug
to my plugin's project file and ran qmake and mingw32-make as usual but this seems to have had no effect.
My project file for the plugin is now:
TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = lib
VERSION = 2.0.0
unix:include(conf.pri)
windows:CONFIG += crypto
windows:include(conf_win.pri)
CONFIG += create_prl
SOURCES = qca-ossl.cpp
windows:{
load(winlocal.prf)
isEmpty(WINLOCAL_PREFIX) {
error("WINLOCAL_PREFIX not found. See http://delta.affinix.com/platform/#winlocal")
}
OPENSSL_PREFIX = $$WINLOCAL_PREFIX
DEFINES += OSSL_097
INCLUDEPATH += $$OPENSSL_PREFIX/include
LIBS += -L$$OPENSSL_PREFIX/lib
LIBS += -llibeay32 -lssleay32
LIBS += -lgdi32 -lwsock32
}
!debug_and_release|build_pass {
CONFIG(debug, debug|release) {
mac:TARGET = $$member(TARGET, 0)_debug
windows:TARGET = $$member(TARGET, 0)d
}
}
CONFIG += debug
Has anyone got any ideas? If you need anymore details just ask, I've tried to be as thorough as possible. Thanks
Tom
I've been struggling with a similar situation: qca-ossl builds fine on linux and not at all on windows. I just hit a breakthrough which might help you as well.
Versions and Patches
qtsdk-2010.05
qca-2.0.3
qca-ossl-r1190163 (from the repository)
openssl-1.0.0b
First of all, if you're using a newer version (0.9.7+, I think) of OpenSsl, you may need to use the qca-ossl version from the repository since it patches some incompatibilities. I also needed to comment out some lines in the new qca-ossl.cpp file dealing with SHA224, SHA256, SHA384, and SHA512 to avoid build errors. I'm using qca-ossl for the ciphers, so I'm not worried about hashing and didn't investigate the errors very much.
Fixing It
The windows build problems were many fold for me, but most of them stem from the shoddy build setup for the windows version of the plugin. It's nice having a little configure script for the linux side of things, but what about windows? We need to do a little extra work.
Some of this extra work is because I've chosen non-standard locations for the support libraries of my application. Qca and OpenSsl both exist within the project's directory structure in a libraries/ directory. My guess is that you've done something similar if you are trying to cross compile your application, but even if you didn't the following should help.
Finding OpenSsl
Qca-ossl wont build very well if it can't find the library it's supposed to connect to... :) So let's specify directly where it is. Comment out the lines relating to winlocal.prf and the changes that stem from it in qca-ossl.pro. We will directly specify where to find openSsl.
TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = lib
VERSION = 2.0.0
unix:include(conf.pri)
windows:CONFIG += crypto
windows:include(conf_win.pri)
CONFIG += create_prl
SOURCES = qca-ossl.cpp
windows:{
# Rather than rely on the winlocal.prf file, we will specify the location of the openssl
# by hand when running qmake.
#
# load(winlocal.prf)
# isEmpty(WINLOCAL_PREFIX) {
# error("WINLOCAL_PREFIX not found. See http://delta.affinix.com/platform/#winlocal")
# }
#
# OPENSSL_PREFIX = $$WINLOCAL_PREFIX
DEFINES += OSSL_097
INCLUDEPATH += $$OPENSSL_PREFIX/include
LIBS += -L$$OPENSSL_PREFIX/lib
LIBS += -llibeay32 -lssleay32
LIBS += -lgdi32 -lwsock32
}
!debug_and_release|build_pass {
CONFIG(debug, debug|release) {
mac:TARGET = $$member(TARGET, 0)_debug
windows:TARGET = $$member(TARGET, 0)d
}
}
Now we have direct access to the $$OPENSSL_PREFIX environment variable in the .pro file. We can set it when we call qmake by doing the following.
qmake.exe "OPENSSL_PREFIX=C:/path/to/openssl-1.0.0b"
You should be able to use backward slashes or forward slashes. Here I choose forward since Qt has deprecated them since 4.7.
Alternatively, you could set the OPENSSL_PREFIX variable directly in the .pro file.
Finding Qca
After comparing the unix and windows makefiles for qca-ossl, oddly enough, it never includes the qca libraries for building or linking! ?!?! This led to an "Undefined interface" error on the Q_INTERFACES(QCAPlugin) line of the opensslPlugin class definition at the end of qca-ossl.cpp.
To avoid this, we will need to explicitly define the include and library paths by hand. Expanding on the qmake line from the last section the final qmake line is as follows.
qmake.exe "OPENSSL_PREFIX=C:/path/to/openssl-1.0.0b" "INCLUDEPATH+=C:/path/to/qca-2.0.3/include/QtCrypto" "LIBS+=-LC:/path/to/qca-2.0.3/lib -lqca2"
"Installing" Qca-ossl
After running the qmake line above and running a plain ol' make, you'll need to install Qca-ossl. You can copy the resulting dll from the lib/ directory to your Qt's plugins directory, which if you're using my versions defaults to C:\Qt\2010.05\qt\plugins\crypto. Alternatively, you can move it to a crypto directory that's at the root level of your project's directory structure such as C:\path\to\my\project\crypto.
I hope this helps!
Actually, you can try this tutorial QCA+OpenSSL on Window. It's work well.
By the way, I can make use of QCA with AES 256 on Window. But i can't use it on Symbian. Any idea to do it?
Related Post