make qt5.3.1 .pro file from Visual Studio 2013 project - qt

I wrote a little Qt utility in VS2013. It works fine when running from IDE - even debugging is great. But VS doesn't generate usable exe (error 0xc000007b - "The application was unable start to work correctly", after I've installed all required qt's dll's).
Is there any way to compile everything and correctly from VS? To make really runnable exe?
Or - How can I write correct pro file for qmake?
I tried to write some. qmake generated from it makefile without any erros, but running VS's nmake it gives a "fatal error: U1077 return code '0x2'".
As I think it is problem with linker - even I wrote for all used modules all required QT += lines.
Can anybody help? I think I'm not alone who met this problem.
Thanks.

When you get an error like you got it means you have some dlls missing. You can only find out what dlls are missing using DependencyWalker.
*.pro files can be generated from Visual Studion using the Visual Studio Add-in for Qt4 or with Visual Studio Add-in for Qt5 depending on your Qt version.
If you have a Qt/VS application you want to deploy, AFAIK the following dlls are needed:
Qt5Core.dll
Qt5Gui.dll
Qt5Widgets.dll
platforms (folder)
qminimal.dll
qoffscreen.dll
qwindows.dll
icuin52.dll
icudt52.dll
icuuc52.dll
YourApplication.exe
For more information see http://qt-project.org/doc/qt-4.8/deployment-windows.html

Related

QT Creator cannot find "objbase.h" when invoking nmake

When attempting to build my Qt project with MSVC2015 64bit for Windows 10, I get this error:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\Ole2.h:37: error: C1083: Cannot open include file: 'objbase.h': No such file or directory
...
NMAKE:-1: error: U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\cl.EXE"' : return code '0x2'
NMAKE:-1: error: U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\nmake.exe"' : return code '0x2'
-- when nmake is invoked during the build process.
This exact same error also occurs for the example project "addressbook".
It appears to be some kind of toolchain issue, but I can compile a Qt Widget project in Microsoft Visual Studio 2022 if I point VS at my Qt installation.
I'm not sure what I need to do from here, since I already tried a reinstall of Qt. I have seen that putting things in Program Files is generally a bad idea, but that doesn't seem to be the issue in this specific case.
It appears to be part of the Windows SDK, if Google leads me right. However, I did not have to download the Windows SDK separately in order to compile my project and run it successfully before. (For context, the project's been developed for a few months and this problem only emerged a week or so ago).
My QT Installation:
Kit: Desktop Qt 5.15.2 MSVC2015 64bit
Version: Qt 5.15.2 MSVC2015 64bit
Compiler: Microsoft Visual C++ Compiler 17.3.32811.315 (amd64)
Things That Have Happened Before My Build Attempt:
I recently reinstalled Qt 5.15.2 in an effort to resolve a similar missing file issue.
The company's recently had issues with Microsoft Intune deleting applications. Maybe it hit the Windows SDK too.
Attempts at Solving the Issue
Reinstallation of Qt 5.15.2
Expected: My project building without errors. Result: This error.
Search of file system for objbase.h
Expected: Finding the file. Result: I did not find the file.
I'm newish at Qt, so I didn't want to try anything more esoteric lest I made things worse than before.
Update: MinGW 64 bit works for the example Qt projects, but I'd still like to use MSVC2015 if possible. It doesn't work for my project because I use some MSVC specific pre-processor flags in my source.
Update 2: I attempted to re-download MSVC 2015 from Visual Studio's website, using their Build Tools installer. While the installation successfully finished, I got no change from before -- it still can't find that "objbase.h" file. It's supposed to be in the Windows Kits directory under Include//um , I think.
It appears that, in my case, the objbase.h file was deleted due to the issue with Windows Defender deleting random files. I was able to reinstall the version of Windows SDK that was using and this fixed the issue for me.
I figured it out. I'm posting the solution here for others.
My issue was that, for reasons that are unclear to me, VS Studio Build Tools would not actually remove the SDK in question if I unchecked its box in the Modify screen. You can tell if this is happening by checking the disk size difference of the upcoming installation in the lower right of the screen -- if it won't remove the SDK, that size will be +0 bytes (assuming you don't check or uncheck any other box).
In order to properly reinstall the SDK version, I had to go to "Add or remove programs" and find the SDK there, uninstall it, restart my computer just for safety, and then go to VS Build Tools and install that SDK version. I had to do a "fake" uninstall with VS Build Tools (basically, uncheck the now-deleted SDK and click "Modify", allowing it to do the installation and download steps) before I could actually install the SDK again.

error while execution of qt .exe file using windeployqt

I have a problem with my qt deployment under windows 10. I'm using QtCreator 4.5.1 and Qt 5.11 on Windows 10. I execute my application in release mode. Then I open the command line by running Qt5.11.0 for Desktop(MinGw 5.3.0 32 bit). There I give the path of the release folder (where my exe file exists):
C:\Qt\workspace\build-CanSaveLog2FilterError2DataExploreClass6-Desktop_Qt_5_11_0_MinGW_32bit2-Release\release
After that I type this line:
windeployqt.exe --quick .
and all the necessary .dll files and platforms and plugins will be generated.
When I do this to a simple qt project, it works fine and my exe file can be executed correctly. Whereas when I do the same to my desired project, I can't execute my exe file and I get this error:
This application failed to start because it could not load the Qt platform plugin "windows"
in "", even though it was found. This is usually due to missing dependencies which you can find by setting the env variable QT_DEBUG_PLUGINS to 1.
Available platform plugins are: windows.
Reinstalling the application may fix this problem.
I tried to find dll file by executing it in dependency walker. When I did this, it showed a lot of dll files missing such as "API-MS-WIN-EVENTING-CONTROLLER-L1-1-0.DLL" which doesn't exist even in bin folder of mingw. While if I put the exe file in the bin folder of mingw it works fine.
So I tried to find all the main dll files whose their sub dll files were missing and copied them to the release folder. For example for API-MS-WIN-EVENTING-CONTROLLER-L1-1-0.DLL, I copied Qt5core.DLL to the release folder. But it didn't work again.
I can't understand where the problem is. Could you please help me to resolve it? Since yesterday morning I'm searching and can't find the solution.

static linking of standard QT libraries

I am trying to build an QT application with version 5.4.
and when ever I am trying to run the exe on a different machine where QT is not installed I am getting below error "The program cannot start because QT5core.dll is missing from your computer, Try reinstalling the program to fix this problem".
and when I copied QT5core.dll with the exe in a machine where QT is not installed its working fine.
Is there any way that I can link QT5core.dll with the exe statically so that whatever place I run this exe it should not ask for any dll.
Thanks,
Tushar
You can build a standalone version of your Qt application so that it doesn't have any library dependencies at runtime. Be warned though: this can greatly expand the size of the .exe generated and the compilation time. Have a look here:
https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows
and here:
https://wiki.qt.io/How_to_build_a_static_Qt_version_for_Windows_with_gcc

How to build Qwt on Windows

Here's what I've done:
Downloaded qwt-4.2.0-setup-qt230nc.exe from sourceforge
Unpack to C:\Program Files\Qwt
Go to Qt Command Prompt
Run msvc-qmake.bat.
Get the output.
Now the lib directory is created, but it's empty. Also tried opening VS project file, but it doesn't converse to VS2008, because there are no vcproj files. I also tried to do it qmake way:
qmake qwt.pro and then make, but it says make is not recognized. I figured that I could use mingw32-make, but I gave me a lot of compiler errors.
I was hoping I would use Qwt within QtCreator, but sadly failed. Any help appreciated.
I think I've come up with easy solution:
Open QtCreator.
Open project... -> C:\Program Files\Qwt\qwt.pro
Build.
...
PROFIT!!!
Do I guess correctly it's valid way to do this?
Now I need to figure out how to marry it with QtDesigner since there is no Designer Plugin in here...
If you have Visual Studio you must to do next steps (according to file "INSTALL"):
run console
change directory to directory where you installed QWT
type "qmake qwt.pro"
type "nmake"
You must be ensured that nmake.exe and qmake.exe in your PATH environment variable.
P.S. Easy way to add nmake.exe (its Visual Studio's make realization) is to run "tools/visual studio 2008 command prompt" from main menu of visual studio.

qt cannot open input file 'c:\Qt\qt\lib\qtmaind.lib'

I am using qt 4.5
I have created a project and I want to compile on visual studio 2008 for windows mobile 6.0
So I have created the project files doing this:
D:\Projects\Phone_PDA\Phone_PDA>set QMAKESPEC=win32-msvc2008
D:\Projects\Phone_PDA\Phone_PDA>qmake -tp vc
The VS project was created. However, when I try and compile I get this error:
LINK : fatal error LNK1181: cannot open input file 'c:\Qt\qt\lib\qtmaind.lib'
However, when I check my librarys and includes under project properties in visual studio. I have this:
Additional Include Directories
c:\Qt\qt\include\QtCore
c:\Qt\qt\include\QtGui
c:\Qt\qt\include
c:\Qt\qt\include\ActiveQt
debug
c:\Qt\qt\mkspecs\win32-msvc2008
Additional Library Directories
c:\Qt\qt\lib
Additional Dependencies
c:\Qt\qt\lib\qtmaind.lib
c:\Qt\qt\lib\QtGuid4.lib
c:\Qt\qt\lib\QtCored4.lib
However, when I browse to the directory c:\Qt\qt\lib all I have is:
qtmain.prl and qtmaind.prl
However, I don't have qtmaind.lib or qtmain.lib
Many thanks for any suggestions,
Are you sure you are using the correct QMAKESPEC?
I would think you would need to use wince*-msvc2008
See Qt: Supported Platforms
Open the Visual Studio command prompt (you can find a shortcut in the start menu). It has all the appropriate environment variables set. Go to C:\Qt\20****\qt. Type configure and then nmake.
Did you download the source distribution? If so you would need to compile Qt before you get the libs.
See:
http://doc.qtsoftware.com/4.5/install-win.html
http://doc.qtsoftware.com/4.5/install-wince.html
My commercial version comes precompiled. If I remember correctly, when I used the open source version I needed to compile everything myself.
First you have to configure the Qt to your machine to get the libs! It will takes several minutes. Follow the steps in: http://portfolio.delinkx.com/files/Qt.pdf
in properties -> linker -> input
remove ANY path for qt libraries such qtmaind.lib
sometime you need remove :
/SUBSYSTEM:WINDOWS%40QMAKE_SUBSYSTEM_SUFFIX%40) from the VS project (under Properties --> Linker --> Command Line).
this is known BUG in VS addin

Resources