문제

I was receiving LNK2019 and LNK2001 errors in VS 2010 but not with g++. I searched around looking for reasons but everything talked about making sure the right headers were included, the functions properly defined, etc.

After going to the project directory and opening the .vcxproj file I saw this list:

   <ItemGroup>
        <ClCompile Include="main.cpp" />
        <ClCompile Include="pilElem3.cpp" />
        ... many lines ...
        <ClCompile Include="utlMatrixFull.cpp" />
        <ClCompile Include="utlVector.cpp" />
    </ItemGroup>
    <ItemGroup>
        <ClInclude Include="pilElem3.h" />
        ... many lines ...
        <ClInclude Include="utlMatrixFull.h" />
        <ClInclude Include="utlVector.h" />
    </ItemGroup>
    <ItemGroup>
        <None Include="pilElement.cpp" />
    </ItemGroup>

pilElement is the parent class to pilElem3 and pilElem4 which were having the linker error.
I didn't change any of the filters or alter the project since creating it.
a) Why did VS think this file should be ignored?
b) How could I notice this sooner?

도움이 되었습니까?

해결책

In answer to how I suspect that you may have inadvertently right clicked on the file in the project explorer - all to easy to do in VS.

How to make sure it doesn't happen in the future you have 2 options a) Don't use visual studio or b) Use a revision control system such as Mercurial and include the project file in those you are controlling - and do regular commits - you will be able to revert changes to the project file if needed and you should notice if it is in the changed file list when you are not expecting it to have changed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top