Search code examples
c++comvisual-studio-2013midltlbimp

MIDL2015 warning when using importlib attribute


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?


Solution

  • 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.