Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Loading a COM DLL (no headers) in QT with C++?
I just started using QT. Right now I need to transfer some code I have on a Visual C++ project to QT.
The only thing the project does at the moment is open photoshop and set the visible flag to false (it will be used for automation, so a lot of things will be added later).
What I do is, I import 2 photoshop dlls (NOTE: I don't have .h or .lib for them, just the .dll files)
The method I'm using to import these dlls is through import libid, since all the other methods I tried didn't work. They are COM objects, btw.
This is my VC++ code:
//library ID of Photoshop.dll
//library ID of PhotoshopTypeLibrary.dll
Photoshop::_ApplicationPtr app( __uuidof(Photoshop::Application));
app->Visible = false;
Now, QT gives me some warnings and errors on the import lines:
warning: #import is a deprecated GCC extension
error: libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E: No such file or directory
And then, after that, it says (obviously) that "Photoshop" is not declared.
Now, I searched and the closest solution I found was to include the .tlh files that were created on my VC++ project, but when I did that, I got more than 1 thousand errors and warnings, so that obviously didn't work.
Can someone please tell me what to do here? I'm seriously stuck!
Which compiler are you using?
I'm using the QT Creator for this
I suppose you are using mingw. Afaik, mingw has no support importing dlls like this. You have to import dlls in project(.pro) file. If you have to import dlls like this, you have to use msvc compiler.
You're right, I'm using MinGW.
I'll check with msvc to see if it works.
With MinGW, however, how would I import the dlls in the project file? I saw some threads about people adding the location of the dll there, however, I don't really have the locations of these dlls (one of the reasons I had to use the libids on the original project)
EDIT: I tried with the msvc compiler. It does compile now, but it crashes saying:
The inferior stopped because it received a signal from the Operating System.
Signal name: ?
Signal meaning: Unknown signal
For reference documentation adding dlls in your project, you can look at LIBS variable in qmake Reference.
giesbert last edited by
#import is a MS specific thing to use native com support.
There are ways for that in Qt, using ActiveQt (see the docs for that).
I know it is possible, but I never tried it on my own.
The other way would be the already proposed one:
use the MS toolchain together with QtCreator
I managed to get it working.
I used the dumpcpp utility from the qt sdk.
In the command line (from QT sdk), I put:
I got the library guid from ole com viewer.
Anyway, it created a .h and .cpp files which I then included in the project, then had to do a couple of adjustments and that's it, it worked!