I have an C++ application, which consists of several VS2010 projects and two Qt Creator projects (for the GUI).
I would like to have a build script, which builds all the projects at once. So what would be the best tool for the job?
Personally, I would change all projects to Qt projects and assemble them using the SUBDIRS template for .pro files.
You could then either run qmake on the top-level .pro file or do
qmake -tp vc -recursive
to create a VS solution and .vcproj files.
If that is not an option, you could just write a batch script which compiles them all. For VS 2008 I had batch scripts like this (File existence checks, error code handling etc omitted):
"%VS90COMNTOOLS%vsvars32.bat"
cd GUI
qmake GUI.pro
cd ..\Core
call vcbuild core.sln "Release|Win32"
The first is needed so vcbuild and nmake etc are known. It could be VS100COMNTOOLS or something like that for VS 2010, you may check your environment variables for that. Or maybe it's not even needed anymore.
Related
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.
I want to create an installer for my Application. So, I have read about Qt Installer Framework and I tested the tutorial example and create the installer and everything work find with the example. But I have a doubt when I try to do the same process for my Application. When I compile the code a folder is created at the same level of my code:
MyApplication (my code)
build-MyApplication-Desktop_Qt_5_4_1_MinGW_32bit-Release (code compiled)
So my questions are:
What files of the compilation do I need to copy into the folder myinstaller/packages/vendor/ recommended by Qt Intaller Framework?
If I have dependencies of Qt like serialport, multimedia, and others, how do I insert these dependecies with Qt Installer Framework?
windeployqt.exe is what you want. Just run that on the command line and give it your executable as the argument. It will automatically copy in all the required Qt libraries and even provide the runtime redistributable installer. Then you can use the binarycreator to generate an installer.
You can put all the dependencies in myinstaller/packages/vendor/data, along with your exe. and eventual additional files. I recommended using i.e. dependency walker for finding all the required dependencies. Some of the binarycreator tutorials on qt are outdated; make sure you use the command
<location-of-ifw>\binarycreator.exe -t <location-of-ifw>\installerbase.exe -p <package_directory> -c <config_directory>\<config_file> <installer_name>
with the appropriate arguments.
I'm using QT (4.7.3) and I'd like to make normal VS solution/project files, build it, and step through the code with debugger to learn the code while reading tutorial...
Instead I have that yet another make qmake which supposed to be able to generate vs solution/project files but it seems that all it generates is some junk empty project files.
Here's what I did (from QT command promt):
cd c:\qt\4.7.3\examples\tutorial
qmake -t vcsubdirs
qmake -t vcapp
qmake -tp vc
but all of them generate random junk or errors...
I assume that I can also generate such solution for entire QT (from c:\qt\4.7.3) to build it from source...
What's the proper way to do it? It has tight integration with VS (designer, add-in etc) it just doesn't make sense that there is no normal solutions/project files there.
Did I do something wrong, or VS is kind of unsupported build platform? :)
Except for a few modes, like -project, qmake expects a valid project file to exist before you run those options. You'll also want to make sure that you're using a QMAKESPEC that corresponds to one of the MSVC versions. This SO post has some good details. To summarize:
Create your project file
Set your QMAKESPEC
Generate the solution file from the project file
That might look something like this:
$ qmake -project
$ set QMAKESPEC=win32-msvc2008
$ qmake -tp vc
qmake -project will regenerate the project file, so don't do that if you have modified your project file at all. The qtnode website also has some good information on using Qt4 with visual studio.
I've been working on a project using OpenCV for a while, and am ready to upgrade my user interface from using cvWaitKey() to get key presses and emulating buttons with trackbars. Ha. So I've decided to use Qt.
I'd like to continue developing in the same directory I've been using, which is, of course, outside of the Qt install directory, C:\Qt\2010.05\qt. Using the "Qt Command Prompt", I'm able to compile the Hello Notepad example in directories both in and out of C:\Qt\2010.05\qt, namely C:\Qt\2010.05\qt\abc and C:\Qt\2010.05\abc.
However, while compiling under C:\ ... \qt produces executables in both the debug and release directories, compiling outside of it only produces the debug executable, along with a .o file (object code?). I did some comparisons using WinMerge, and found that the following lines (among others) differ in the two makefiles (generated using qmake -project and then qmake):
Inside qt\
first: all
install: debug-install release-install
uninstall: debug-uninstall release-uninstall
Outside qt\
first: debug
install: debug-install
uninstall: debug-uninstall
That's clearly the problem (the .pro files generated by qmake -project differ only in timestamp). I'm sure there's an easy answer out there to what's causing this... I hope there's an easy answer to how I can work around it. Also, I intend to use QtCreator some; hopefully the solution is the same for the IDE as the Command-Line compiler.
Thanks!
Nolan
p.s.: I don't think this is the same issue: Qmake does not support build directories below the source directory ...in any case, I'm not sure I understand the answer.
You should be able to add
CONFIG += release
to your .pro file, to build for release target. There's also
CONFIG += debug_and_release
iirc.
QtCreator has a GUI element for toggling between build targets, you might try opening the .pro with that application if you find you need to switch back and forth often.
I've got a buildenvironment based on Qt .pro files transformed to both Visual Studio 2008 solutions and Makefiles (used by nmake). There are about 30 projects, untill recently all compiled into a seperate dll (and the main into an exe).
Recently I added a project configured as static lib. Visual Studio links everything just fine. nmake has unresolved externals to every symbol used from this static lib.
Project sequence in the Makefile is OK
Qt's dependencies are OK
used:
Visual Studio 2008
Qt Visual Studio Integration 1.4.3
Qt 4.5.2
Any suggestions? All the logs combined, or any usefull selection of them, are too way big to post.
When parsing the LIBS variable, for each entry -l qmake goes looking whether or not the file exists in the libpath. If it can find it, it adds an absolute link to the Makefile, if not it just adds the filename and lets nmake look for it itself.
I had 2 entries: -lmystatic and -lmystatic2. The first time I generate my Makefile's, it writes:
LIBS = ... mystatic.lib mystatic2.lib ...
If I regenerate my Makefile's, it should write:
LIBS = c:\sandbox\bin\mystatic.lib c:\sandbox\bin\mystatic2.lib
instead, it writes:
LIBS = c:\sandbox\bin\mystatic2.lib c:\sandbox\bin\mystatic2.lib
What I think happened is that qmake takes the list of all files that match "mystatic", and takes the first one. Unfortunately "mystatic2.lib" also matches this AND "mystatic2.lib" ends up lexically BEFORE "mystatic.lib".
The Qt Visual Studio integration does the exact same thing. VS filters out the duplicate but a .lib entry is missing along the includes. I haven't been able to find out why VS is able to link like this.