1

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
#import "libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E" 
//library ID of PhotoshopTypeLibrary.dll
#import "libid:4B0AB3E1-80F1-11CF-86B4-444553540000" 

int main()
{
    Photoshop::_ApplicationPtr app( __uuidof(Photoshop::Application));
    app->Visible = false;

    return 0;
}

Now, I'm using the QT Creator with MinGW to compile this code, and it 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!

3
  • #import is not standard C++, where did you read about that? Commented Jan 31, 2012 at 10:00
  • I'm just trying to find out how to do that in QT, like, what would be the equivalent way Commented Jan 31, 2012 at 10:16
  • You can compile Qt code with MSVC (by using the Qt VS add-in in Visual Studio, not Qt Creator). Is anything preventing you from doing that (since COM is Windows-only anyway...) ? Commented Jan 31, 2012 at 10:42

1 Answer 1

1

#import is a Microsoft extension that you can use to import COM libraries in VisualC++.

From your question it looks as if you have access to VisualC++ but that your QT code is compiled with gcc.

If you create a simple project in VisualC++ you can add the #import code and compile it. You will find that the compiler has generated a .tlh and .tli file. These files contain all the information that you need to use the COM library and can be used by any compiler.

You can then copy these files to your gcc project directory and use #include (not #import) on these generated files.

The .tlh is equaivalent of a c++ header, the .tli is more like a .cpp file.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for the reply, morechilli. However, as you can see near the end of my post, I have already tried that and it didn't work, it gave me more than a thousand errors. Do you have any other suggestions?
It should be the correct approach. With that number of errors there are probably 1 or 2 systematic issues repeated multiple times. #import has a number of options for excluding base libraries or adding namespaces to avoid clashes. If you post a few examples of errors that might give more information.
He'll need the headers for comsupp.lib to get the .tlh/i files to compile (comdef.h etc). Not available on mingw, thousands of errors. Only a complete rewrite using native com will do.
I've never used QT but it looks like it comes with an implementation for supporting use of COM objects - see this question stackoverflow.com/questions/8211459/qt-using-shared-com-object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.