Dll loaded by application only in qt debugger but not independently - c++

After cleaning and reinstalling windows 7, I've installed qt 5.11. However, my old plugin (dll) which I developed using qt 3 is no longer recognized by the application. But the application recognizes the dll in debugger mode.
I have tried copying dependent libraries which the debugger loads to the dll location but this has not worked. I have also removed references to qtcore etc but even this has not worked. I do not know what I am missing.The plugin ran fine in the old version of qt but not in the newer version of qt.
Thanks for any help that you can give.

Qt does not provides binary backward compatibility between major versions.
You must update (== compile and build your plugin dll with Qt5) to have it working.
see this page
https://wiki.qt.io/Qt-Version-Compatibility#Binary_Compatibility_Guidelines

Related

Do QT based GUI applications work in Windows PE?

I tried running a QT C++ GUI sample in WinPE. It should just open an empty window.
It complains about missing d3d11.dll and dxgi.dll.
QT tries to use OpenGL, if there is no suitable driver, it uses DirectX with ANGLE. I tried removing the DirectX dependency by calling Qapplication::setAttribute(Qt::AA_UseSoftwareOpenGL) before the Qapplication instantiaton. No change, still requires those two dlls.
I tried to copy those two files from my regular Windows, and now the error is: “The procedure entry point CheckIsMSIXPackage could not be located in the dynamic link library dxgi.dll”
I don't need any HW acceleration, how could I make it run?
QT version: 5.14.2 (dynamic linking)
WinPE version: Windows 10 2004
Compiler: Visual Studio 2019 and Mingw 8.1 (I have tried both, same results)
Too late ? Not the solution but only an idea.
Actually I use Winpe WinPe 2009. When i install VirtualBox 6.1.16 in this winpe, i add opengl32.dll and other files. VirtualBox uses QT5 files. And i get the same error. With Depends.exe, i see that opengl32.dll needs this ChechIsMSIXPackage and loock for it in kernelBase.dll. But because kernelBase.dll which comes with winpe2009 doesn't contain this API, i take this kernelBase.dll from a normal W10 (in the ISO/Install.wim). And, in my case, virtualBox works well, QT5 also, opengl32 also.
Qt 5.12 does not depend on dxgi.dll but Qt 5.15 definitely seems to.
One option is to roll back your project to Qt 5.12, I can personally confirm that Qt 5.12 projects work great under Windows PE.
(This is assuming you are using the prebuilt Qt binaries from Maintenance Tool - otherwise there may be a config option to recompile Qt to avoid this).
It's late but since I just ran into this problem myself...
Apparently this dependency is introduced by the Rendering Hardware Interface, and what worked for me for WinPE 1809 was to build Qt 5.15 (.7 and .8) from source - in Msys2, by the way - after removing/commenting out the line include(rhi/rhi.pri) in qtbase/src/gui/gui.pro, and the configure command line includes -no-directwrite -no-opengl -no-icu.

Make "Add Qt Sources" work for Qt SDK on Linux (NOT built from source)

This is similar to my question about Step into Qt Sources from Qt Creator on Windows (NOT built from source), but I can't make it work for Linux.
Instead of building from source, I have downloaded the Qt SDK installer, and I've installed Qt to /opt/Qt, and I have the sources at /opt/Qt/5.4/Src.
I cannot step into Qt Sources, so I tried adding a Source Mapping using "Add Qt Sources":
I have tried mapping /var/tmp/qt-src to /opt/Qt/5.4/Src, /opt/Qt/5.4/Src/qtbase, and /opt/Qt/5.4/Src/qtbase/src, none of which worked.
What am I doing wrong? Is the source mapping not /var/tmp/qt-src, or is the target mapping wrong? Does "Add Qt Sources" work at all for the Qt SDK?
I saw a suggestion in a forum thread that it's because the Qt SDK for Linux ships only stripped binaries, while it ships both debug and release DLLs for Windows (which would explain why it worked for Windows, but not for Linux).

Qt 5.4.0 deployment issue - missing vsprintf_s in msvcrt.dll

I'm stuck in a deployment issue with my Qt 5.4.0 application.
After two days of research, my app really doesn't want to execute on Windows XP !
I have created my deployment folder with windeployqt provided by my Qt installation. When I double-click on *.exe, I have always :
The procedure entry point vsprintf_s could not be located in the dynamic link library msvcrt.dll.
Dependency walker hasn't really helped me and I don't know what I can try now.
Note :
SDK : Qt 5.4.0 (MSVC 2010, 32 Bits)
IDE : QT Creator 3.3.0
Compiler : MinGW 4.9.1 32 Bits
Need to run on : Windows XP Pro SP2 32 Bits
App works like a charm on Windows 7 with same configuration (IDE, compiler, etc.)
While Guilhem G. is correct in the broader sense, it doesn't mean you actually called that function yourself (speaking now to a theoretically other person running into this issue like me, heh). I believe it's a bug with MinGW's XP support; I've seen bug reports of similar issues, including nearly the exact same issue in a much earlier version of Qt that was then fixed. I haven't seen this particular incarnation, which I actually ran into myself. I suppose I should probably submit a bug report!
Anyways, I've fixed it without changing any of the code I've written myself. What I had to do to fix it was twofold:
Switch over to using the msvc2010 compiler, since that set of C++ libraries rather unsurprisingly runs fine on Windows XP (AFAIK they still haven't dropped XP support with the latest version).
Switch over to Qt 5.5 (I'll explain why at the end).
For the compiler, you'll need then either Microsoft Visual Studio 2010 (hence the name), or the older Windows SDK that ships with it; the "Microsoft Windows Software Development Kit for Windows Server 2008 and .NET Framework 3.5" release should do the trick for you if you don't have a Visual Studio 2010 license.
Once one of those is installed, I'd encourage you to install Qt 5.5 as compiled by MSVC2010. You can either start a fresh installer or use the Qt Maintenance Tool which should already be installed.
Once that kit is installed, within your project (selecting "Projects" from the left-side menu) you should be able to go "Add Kit" and select Qt 5.5 msvc2010 32-bit, and if you now recompile and redeploy your application, it should run fine on XP.
Now, why did I insist on you upgrading to Qt 5.5? Well, there's some underlying issues with choosing a working OpenGL renderer on each version of Windows, and Qt 5.5 simplifies that a lot by having it fall back on OpenGL or ANGLE depending on what capabilities are actually detected, plus IIRC some other related fixes. So certainly if you're deploying a QML / Qt Quick 2.0 app across multiple Windows versions like I'm doing, it's worth upgrading to Qt 5.5.
The error was I called "sprintf_s" somewhere in my code (ok for recent windows on my dev machine but not for XP).
If you have the same problem when you search in your code don't use exactly the name of the function in the error message but an expression like *_s.
You probably call a secure API function somewhere !

QSystemTrayIcon in ubuntu, sni-qt

I'm using Ubuntu 12.04 64-bit.
I built qt libraries (qt-everywhere-opensource-src-4.8.2) and want to use them when building my application, and deploy them with my application.
I want my app to have system tray icon, so I'm trying to use QSystemTrayIcon class, but the icon doesn't show.
After some research I found out that it has something to do with sni-qt plugin. But I couldn't find any information on how to use it in my code. Or the qt libs must be patched to use it? Because if I link to qt libraries preinstalled in the system, the icon shows.
The question is how can I make system tray icon appear and function using my manually built qt libraries? Is it possible
Qt will refuse to load a plugin compiled against a different Qt version (or with a different compiler, or a different Qt setup). Hence, you need to build that plugin as well using the same Qt version your application is using. Grab its sources and compile it.

How to organize Qt DLLs with Qt-based dependency

I have a Qt application using Qt 4.8.5. This application is dependent on a DLL that was built using Qt 4.6.0. Let's call it "MyDLL.dll".
I cannot rebuild MyDLL.dll to update it to a more current version of Qt. Since both my application and MyDLL require the QtCore and other DLLs, and the versions are different, how do I organize my files such that they don't conflict?
MyDLL is required at startup, so I can't use any delay load methodologies.
edit: To be clear, this question came up because the MyDll.dll was built using a custom Qt 4.6.0 from modified source, and my application is using a custom build of 4.8.5. The modifications weren't necessarily the same in both versions, so I didn't want to assume that I could still use the 4.8.5 DLLs. Turned out that it worked out in this case, but the question stands.
You shouldn't be having any issues. Qt maintains binary compatibility over minor and patch releases (see http://qt-project.org/wiki/Qt-Version-Compatibility) and an application/DLL built with 4.6.x will run fine when bound to 4.8.x runtime.
Your MyDLL.dll built with 4.6.0 will run with 4.8.5 runtime DLLs.
Your application built with 4.8.5 will run with 4.8.5 runtime DLLs.
Your application will run fine with MyDLL.dll as long as you are using the same interface you've always been using.
If you are seeing issues it is because of something else, and you will need to clarify exactly what problem you are having.
If you are not seeing issues and are just asking preemptively, then 1) just proceed as normal with no special considerations, and 2) you should have tried it first!
Welcome to DLL Hell! :(
This is a huge problem under Microsoft windows, since the standard isn't to build version information into the DLL file name (like with Linux .so files).
You won't be able to accomplish what you are after if you link directly against "MyDLL.dll" since it will be looking for QT DLLs (like QtCore, QtGui, etc). The stock Qt DLLs contain no version decoration in the filename, so there will be a conflict as to which one to load. Also, you will likely not be able to link correctly in the first place (due to the conflicts. Qt doesn't play well with older versions).
The only possibility might be to create a separate executable that links against Qt 4.6.0 and MyDLL, and use some out-of-process communication between your main app and the server. COM might work in this case, but it largely depends on what your dll actually does.
The only other course of action would be to downgrade your main application and fix it at Qt 4.6.0.
Jason C's answer got it right. Also note the following:
MyDll.dll must be compiled with the same compiler version as the rest of your application.
The version of Qt used to build MyDll.dll should have had the same major configuration flags as the version of Qt that you're currently using. Things such as Qt namespaces, QThread support, etc. must all be the same.