How to generate Qt .pri files from Visual studio project at the end of the build? - c++

Can I setup my solution in visual studio to automatically generate the .pri files at the end of the build? I thought about perhaps writing a batch file to call a command to generate the .pri files, is it possible to generate .pri files from the command line?
I am working on a Qt C++ application in visual studio made up of 9 subprojects. I also created a QMake based build of the same application using Qt visual studio add in to generate the .pro and .pri files.
The setup is working well, and the application compiles successfully on Windows (using VS2010) and Mac OS X (Qt creator). The problem is that every time I change the projects in visual studio (for example by adding or removing source files), I have to manually regenerate the .pri file for the project so it gets picked up by qmake.
I'm using the Qt visual studio add in v1.1.11. Visual studio 2010, Qt 4.7.4.

I created a small python script to generate .pri files from visual studio .vcxproj.filter files, I've added it to our post build script that runs at the end of the visual studio build, and it seems to work quite well. If anyone else wants it, you can find it here:
https://github.com/JamesSmaldon/prigen.git

You know, Visual Studio is independent on Qt environment. The only opportunity to do what you want is use of some VS plugins, but I've never actually seen such an option anywhere.
As for me, when I add some file to VS solution, I append it manually to the *.pro file.

Related

Required to update Qt .pro and Visual Studio .vcxproj on new file additions

I'm developing using Qt Creator and Visual Studio. However, if I add a new file to the project through Visual Studio the Qt .pro file is out of sync and does not show the new file. Additionally, if I add a new file via Qt Creator the .vcxproj file doesn't get updated and therefore Visual Studio is out of sync.
I am using Visual Studio on Windows and Qt Creator on Linux.
Is there a proper way to manage this type of situation or is this something I just need to keep updated manually if I want the two project files?
There are a few options:
1) Use only Qt Creator, since it runs on both windows and linux it's an good option.
2) Only use the .pro to add files (options/etc), basically only use qmake build system to modify the anything build related and after each change re-create the VS files by using Open Qt project file (.pro) from Qt menu in Visual Studio.
3) Use a completely different build option that can be used on all the platforms you need, for example cmake is a good option and both Visual Studio and Qt Creator have support for it (i didn't used it, so i don't know how easy it's to setup, but i assume it should be relatively easy).

compiling c++ projects with sln file in ubuntu

This may be a stupid question, but I've been trying to compile a larger project that was originally associated with visual studio in Ubuntu. I settled on cmake to do this, but it needs a cmakelist file. As I don't want to set this up manually, since I'll have to port several thousand pages like this, is there a way to have cmake read the sln files visual studio generates?
Any way that would let me compile the projects automatically on Ubuntu would be great.

MSVC2013 - Entry Point Not Found

I recently installed the Qt add-inn for visual studio 2013. When I build a project in either Qt Creator or Visual Studio using MSVC2013 it builds without errors, but can only be run from inside the IDE. If I try to run it by clicking the .exe, it gives an error: "The procedure entry point ?qt_metacast#QMenuBar##UAEPAXPBD#Z could not be located in the dynamic link library".
From the research I have done online, I found that it could be something to do about adding the correct .dll files in my .exe directory. Which .dll files do I need or is there something else I'm doing wrong?
I installed the Visual Studio Add-in 1.2.4 for Qt5 from the Qt website.
DLLs for this kind of libraries use to be unnecessarily big. You should make a Qt static compilation so that your needed functions are embed into your *.exe.

Qt Compilation - Using qmake on Windows

I'm having a bit of trouble trying to compile Qt programs under Windows. I'm on a work machine so I'm trying to be wary about what things I'm installing/setting up etc since I was given a procedure to follow originally to get this working (That didn't work), so please keep that mind.
My development environment is normally Visual Studio on Windows 7. To install Qt I unzipped a few files into C:/Qt and setup my environmental variables to reflect it. I've written a short example file in Visual Studio and was able to have it compile; however things got tricky once I started using more than one file in the project.
For example:
Attempt 1 - Only had 1 .cpp file; ran 'qmake -tp vc projectname.pro' then went back into Visual Studio and loaded in the project, Built, and ran the file fine.
Attempt 2 - Had the original .cpp file, added a .h & .cpp to reflect a popup dialog, ran 'qmake -tp vc projectname.pro', loaded in the project, and my two new files were gone.
So two questions here:
1) How do I have multiple files when working in Visual Studio?
2) If I'm making a file from scratch just using notepad, how do I proceed? (ie: I make projectname.cpp, Use the designer to create the .ui file, run 'qmake -project' and 'qmake -tp vc projectname.pro' and the .ui file is not converted into the .h file as it's apparently supposed to do.
Reading "C++ GUI Programming with Qt Second Edition (ISBN-13: 978-0-13-235416-5) if it's of any help.
Thanks,
Thomas
Install the visual studio addin (*) it detects the Q_OBJECT macro and handles all the extra build steps
If you want to use qmake it's described here, it's a nicer simpler format than regular makefiles and the VS addin-can convert between .pro files a visual studio solution.
(*) scroll down to other downloads, select version 1.1 for Qt4 or 1.2 for Qt 5

use msbuild to compile a vcxproj created by vs2010 on a computer without vs

I have created a large Visual C++ 10.0 project which builds nicely within the visual studio ide as well as within the "special" Visual Studio Command Prompt using msbuild with a vcxproj file.
However this project needs to be compiled by computers that do not have the vs ide, but only have the msbuild tool and the vc++ 10.0 runtime files.
The problem is that the vcxproj (created by the vs ide) file contains references to files such as Microsoft.Cpp.Default.props and Microsoft.Cpp.targets which clearly won't be available in a computer without visual studio.
Since all the compile and link command line options are available and fixed (no changes will be necessary), how is it possible to create a new vcxproj file to implement the compiling and linking of the project using these options?
I was finally able to make some tests on a "clean" computer. These are the results:
First, I installed .NET Framework 4.0 from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17718. Along with it, MSBuild 4.0 was also installed automatically. When I tried to compile I got the following error:
error MSB4019: The imported project "H:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
which means that extra files are needed to compile the vcxproj and these files were missing. Note that simple project files written by hand (and not by the VS IDE) are expected to compile without problems since they contain no references to theses files (I did not test it for certain).
Next, I installed Windows SDK 7.1 from http://www.microsoft.com/download/en/details.aspx?id=8442. The error about missing files disappeared, but I got a new one. This new error (along with the way I overcomed it) is described in http://www.damirscorner.com/CommentView,guid,9121bd6b-876c-4051-8487-de1b95a7e919.aspx.
Doing the above successfully allowed me build my vcxproj file on a computer without vs2010.
I think that the files that you mention are not part of Visual Studio. They are part of MSbuild.