65.9K
CodeProject is changing. Read more.
Home

Generate TLB for Arbitary IDL in Build

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Aug 27, 2013

CPOL
viewsIcon

11280

To generate a TLB file for an IDL file in build

Sometimes, you have multiple IDL files in your ATL project. By default, you will only see one TLB file generated after build. But how to generate a separate TLB file for a specific IDL file?

You could follow the steps below to achieve this goal:

  1. Open your ATL project (assuming it is A.vcxproj) in Visual Studio.
  2. Right-click the project and click "Unload Project".
  3. Right-click the project again and click "Edit A.vcxproj".
  4. Find the IDL file name (assuming it is M.idl) in the editor. It should be within a <Midl> tag.
  5. Add <TypeLibraryName> tags inside <Midl> and condition them with your build configurations and platforms. An example is as below:
<Midl Include="M.idl"> 
  <TypeLibraryName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">M.tlb</TypeLibraryName>
  <TypeLibraryName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">M.tlb</TypeLibraryName>
  <TypeLibraryName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">M.tlb</TypeLibraryName>
  <TypeLibraryName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">M.tlb</TypeLibraryName>
</Midl> 

Then M.tlb for your M.idl will be generated to your source code folder in build.