fatal error C1084: Cannot read type library file: 'Smegui.tlb': Error loading type library/DLL
Asked Answered
F

4

5

I am trying to build an old version of an application which consists of VC++ projects that were written in Visual Studio 2003.

My OS is Windows 7 Enterprise (64-bit). When I try and build the solution I get the following errors:

  • error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder
  • fatal error C1084: Cannot read type library file: 'Smegui.tlb': Error loading type library/DLL.

They both complain about the following import statement:

#import "Smegui.tlb" no_implementation

This is not a case of the file path being incorrect as renaming the Smegui.tlb file causes the compiler to throw another error saying it cannot find the library.

Smegui is from another application that this one depends on. I thought perhaps I was missing a dll but there is no such thing as Smegui.dll.

All I know about .tlb files is that they are a type library and you can create them from an assembly using tlbexp.exe or regasm.exe (the later also registers the assembly with COM)

There is also an Apache Ant build script which uses a custom task to invoke devenv.com to build the projects. This is the same script that the build server originally used to build the application. It gives me the same errors when I try and run it.

The strangest thing about this is that I knew it ought to work seeing as it is all freshly checked out from subversion. I tried many different combinations of admin vs user elevation, VS vs Ant build, cleaning, release.

I have got it to build successfully about 5 times but the build seems to be non-deterministic.

If anyone can shed some light on how this tlb stuff even works or what this error might mean I would greatly appreciate it.

Frequency answered 16/6, 2010 at 0:47 Comment(0)
F
10

I found a far more reliable solution: open the tlb with oleview.exe and then close it.

Not sure what this actually does but it works every time.

I think oleview is actually one of the samples included with Visual Studio but I haven't had the time to debug it and see what it is doing.

Frequency answered 5/10, 2011 at 22:37 Comment(2)
Solved mine as well, you saved me on this :)Millisent
Used to work for me as well, but in the last years (probably after 64bit OS?), OleView hangs when it supposed to add missing TLB registrations :(Tournai
V
5

I ran into this error because one type library was trying to load a dependent type library, which it could not find. Even though the dependent type library was in the same directory, and even though that directory was in the searchable path, the compiler would error loading the first type library, but not mention the dependent type library in the error.

To find the pseudo-missing type library, I ran Process Monitor (procman64.exe) during the compile. This showed that after the reported type library had successfully loaded, a dependent type library could not be found. It even showed all of the places that it was looking for the dependent type library, none of which were where it should have been looking (e.g.: procman output).

The fix was to add a <PreBuildEvent> to the project to copy the dependent .tlb file to one of the directories that was actually being searched.

<PreBuildEvent>
  <Command>copy /Y ..\Lib\Interop\CWSpeechRecLib.tlb .\</Command>
</PreBuildEvent>
Vitiated answered 7/8, 2018 at 23:11 Comment(1)
Thanks man, using ProcMon helped me after half day fight of fatal error C1084: Cannot read type library file: 'xxxxxxxxxx': Error loading type library/DLL.Tournai
M
4

http://msdn.microsoft.com/en-us/library/sce74ah7%28VS.71%29.aspx

smegui.tlb is referencing some other tlb that the compiler can't find. If you have the .idl for smegui you might be able to figure out what the other is. I suspect the missing tlb is something that original build machine had registered but that your machine doesn't have registered.

A type library is a binary description of a set of interfaces, coclasses and enums. They're usually generated for COM components, in the case of tlbexp and regasm the tlb is created from the assembly metadata. For native COM components they are usually generated from an idl (Interface Description Language) file by the midl tool.

Edit:

I just noticed you're on x64 Windows. Are you building the project with a new version of Visual Studio? If so, are you targeting x86 or x64? If the latter, it may simply be a 32bit component that the compiler can't find (or less likely, a x64 component the x86 compiler can't find if you are targeting x86), for WOW64 the registry is virtualized for x86 vs. x64 applications.

Marquesan answered 16/6, 2010 at 0:57 Comment(1)
Thanks for your help. That's good to know about the idl. C++ is definitely not my strong point. Yup was running the build release for Win32 and other dependencies were also 32bit.Frequency
F
1

Well I finally found out why I managed to get it to build sometimes and not others... sort of.

So long as I ran the build script with elevated administrator permissions and let that get as far as it could until that error occurred, then run the build script again as a protected administrator succeeded. Those steps must be done in that exact order with no other steps in between. If I try build in Visual Studio it does not work (although I did get it to succeed once). Probably some kind of virtualisation issue although it still doesn't quite make sense.

Well I don't need help on this any more and I know it's probably impossible to fully answer this question without knowing exactly what the build is doing. However if anyone does have any more thoughts I would happily receive them.

Cheers,

Steiny

Frequency answered 17/6, 2010 at 21:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.