2

I have a legacy Visual Studio solution which contains several projects (has been upgraded to Visual Studio 2013). One of these projects generates a COM DLL. The TLB from this DLL is then imported into an IDL file of another project via the importlib attribute. When the MIDL compiler tries to compile the IDL file of the dependent project it generates the following warning:

warning MIDL2015: failed to load tlb in importlib

When I use the full path to the TLB file it works.

I have tried adding the path to the MIDL -> Additional Include Directories property but I think this is only for IDL, header, and ACF files (/I switch).

I've also tried the Linker -> Additional Library Directories property but this didn't work either.

What search path does MIDL use when resolving the importlib attributes?

steinybot
  • 5,491
  • 6
  • 37
  • 55
  • I guess you should use a relative path to the other project - you build them one after another, don't you? – sharptooth Jul 15 '14 at 06:41
  • Except that they go to directories based on the build configuration. I guess I could get around that with #ifdefs (if that works with the MIDL compiler). I couldn't work out a way of adding a suffix to the TLB file (E.g. D for debug) without breaking the RC file. – steinybot Jul 16 '14 at 03:45

1 Answers1

5

It is unintuitive, midl.exe doesn't have a command line option to specify the directories to search. Note how midl.exe never has a problem with importlib("stdole2.tlb"), a file that's stored in c:\windows\system32.

Project + Properties, VC++ Directories, append the path where the .tlb is stored to the Executable Directories setting. After you're done and you've added, say, "c:\temp", it should look like "c:\temp;$(ExecutablePath)".

Not so sure that wins a lot of prizes. Having the .tlb generated or stored in a more predictable path so you can use a relative path in your importlib directive causes less head-scratching surprises a year from now.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Had to read that a couple of times but I see what you mean now, thanks. That's a lot better than anything else I could come up with. I was fumbling around trying to replace the importlib with an import with the IDL file. Wasn't really sure what I was doing though tbh. Still trying to learn what all this stuff means and how to use it. – steinybot Jul 16 '14 at 03:53