Generate TLB for Arbitary IDL in Build





0/5 (0 vote)
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:
- Open your ATL project (assuming it is A.vcxproj) in Visual Studio.
- Right-click the project and click "Unload Project".
- Right-click the project again and click "Edit A.vcxproj".
- Find the IDL file name (assuming it is M.idl) in the editor. It should be within a
<Midl>
tag. - 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.