Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / ATL

Generate TLB for Arbitary IDL in Build

0.00/5 (No votes)
27 Aug 2013CPOL 11.3K  
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:
XML
<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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)