views:

41

answers:

1

I am maintaining a VS2010 project which has a number of cross-referenced COM libraries. I am trying to configure the project in such a way that it is buildable from a random workstation which has VS2010 installed. The workstation could be both 32 and 64 bit, so if I configure project to "register output", the build will fail to build on 32-bit machine, since 64-bit DLL will not be possible to load to call DllRegisterServer.

Here is an example: Typelib from project B references typelib from project A. Project C will reference project B via following statement:

#import "B.tlb"

Since library B references A, when B.tlb is being imported, the compiler tries to load types from A. So, if A is not registered, the compile will fail with:

error C4772: #import referenced a type from a missing type library ...

I tried to open B.tlb using the OleView application, and it's sure as hell only showing right file name for library A reference if it is registered using regsvr32.

So, my question here is: is there any alternative way for library references to resolve themselves properly, without having to register TLBs, just by putting all the files in the same directory somehow, or attaching some sort of manifest? For example, rename the TLB for a library as .tlb or something of that sort.

A: 

Try import the referenced A.tlb first, or list it in the import of B.tlb using the include() option.

Only #import the parts of the interface you plan to use if you can avoid bringing in other references unnecessarily.

Greg Domjan
Can I have some more info on the include() option? I already have all the tlb files in the directory which is a C++ include directory, if that's what you are referring to
galets
Are you referring to this: http://msdn.microsoft.com/en-us/library/8etzzkb6(VS.71).aspx#vcreftheinclude(...)attribute ? I don't think you can use this to import additional typelibs
galets
Yes I was referring to that. The way I read it, it includes additional type libraries that should be present. I've not used the option before myself, just a suggestion.
Greg Domjan