I have been asked to help a colleague regarding a mysterious build error in one of the projects in a common solution. The build error happens in the linkage stage, a class constructor defined in a static lib (a.lib) is not found when it is used in a lib (b.lib) that includes that a.lib. After careful investigation I figured out that:
- The constructor is correctly defined in the class.
- The class is defined in a cpp file that belongs to the project.
- If a try to navigate to the cpp file or the class constructor with intellisense everything goes as expected.
vcxproj file ClCompile ItemGroup:
...
<ClCompile Include="Source\CMYKOVBLab.cpp" />
<ClInclude Include="Source\CMYKOBGLab.cpp" /> <--- The file is here.
<ClCompile Include="Source\CMYKOVBRGB.cpp" />
...
In summary, what is needed to link the library is there, but the linkage error persists.
One strange thing I noticed is the fact that the cpp with the class constructor not found could not be compiled by hitting Ctrl-F7 or the right button in a.lib. That option is grayed out, but only for that particular file. Moreover, when I build the a.lib library where this file should be compiled, it is not, and therefore no object file is created.
What can be the cause? How can I fix it?
I am using Visual Studio Professional 2015 Update 3.