3

I have a c++ project that is importing two .tlbs in a header file.

#import "..\bin\derived.tlb" named_guids raw_interfaces_only
#import "..\bin\base.tlb"  named_guids raw_interfaces_only

Now derived.tlb is dependent on base.tlb. There are base classes in base.tlb that classes in derived.tlb are based on.

When I compile, I get

"fatal error c1084: cannot read type library file '..\derived.tlb': Error loading type library/DLL."

Now it's complaining about derived.tlb but the problem seems to really be in not being able to find base.tlb.

base.tlb comes from a C# Com interop project. If I check the "register for com interop" in the build tab of the c# project, this problem goes away in the c++ project. But I don't want to register it. This gets built on a build machine which shouldn't have anything registered on it. So I create the .tlb with a post build step to tlbexport.

The tlb gets created in the correct folder but it appears that without the registration, #import can't find the base.tlb when importing derived.tlb.

I see in process monitor, it's trying a hell of a lot of places to find base.tlb but not the correct folder that equates to ..\bin\.

What can I do to get it searching in the right place? Adding an entry for it in "Additional Include Directories" in the c++ project doesn't seem to help.

VividD
  • 10,456
  • 6
  • 64
  • 111
Dan G
  • 836
  • 11
  • 31
  • Maybe I just need to copy the appropriate tlbs to a directory I'm sure the c++ code will be able to reach it? I can see from proc monitor all the places it's trying. I can just select one of those directories to copy the tlb to with a prebuild step – Dan G Mar 24 '14 at 19:03
  • Use the Additional Include Directories settings instead of ..\bin. Don't import base.tlb – Hans Passant Mar 24 '14 at 19:43
  • That's even better. Thanks! – Dan G Mar 24 '14 at 20:02

0 Answers0