Building project under VS2013 works only when each

2019-09-14 18:22发布

问题:

I'm trying to compile Ogre Wiki Tutorial Framework 1.9 - (Windows line endings) in VisualStudio 2013. Right click on OgreFramework project and choosing Rebuild returns following errors:

Error   487 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::windowClosed(class Ogre::RenderWindow *)" (?windowClosed@BaseApplication@@MAEXPAVRenderWindow@Ogre@@@Z)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   488 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::windowResized(class Ogre::RenderWindow *)" (?windowResized@BaseApplication@@MAEXPAVRenderWindow@Ogre@@@Z)    c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   489 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::mouseReleased(class OIS::MouseEvent const &,enum OIS::MouseButtonID)" (?mouseReleased@BaseApplication@@MAE_NABVMouseEvent@OIS@@W4MouseButtonID@3@@Z) c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   490 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::mousePressed(class OIS::MouseEvent const &,enum OIS::MouseButtonID)" (?mousePressed@BaseApplication@@MAE_NABVMouseEvent@OIS@@W4MouseButtonID@3@@Z)   c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   491 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::mouseMoved(class OIS::MouseEvent const &)" (?mouseMoved@BaseApplication@@MAE_NABVMouseEvent@OIS@@@Z) c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   492 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::keyReleased(class OIS::KeyEvent const &)" (?keyReleased@BaseApplication@@MAE_NABVKeyEvent@OIS@@@Z)   c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   493 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::keyPressed(class OIS::KeyEvent const &)" (?keyPressed@BaseApplication@@MAE_NABVKeyEvent@OIS@@@Z) c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   494 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::frameRenderingQueued(struct Ogre::FrameEvent const &)" (?frameRenderingQueued@BaseApplication@@MAE_NABUFrameEvent@Ogre@@@Z)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   495 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::loadResources(void)" (?loadResources@BaseApplication@@MAEXXZ)    c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   496 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::createResourceListener(void)" (?createResourceListener@BaseApplication@@MAEXXZ)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   497 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::setupResources(void)" (?setupResources@BaseApplication@@MAEXXZ)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   498 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::createViewports(void)" (?createViewports@BaseApplication@@MAEXXZ)    c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   499 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::destroyScene(void)" (?destroyScene@BaseApplication@@MAEXXZ)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   500 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::createFrameListener(void)" (?createFrameListener@BaseApplication@@MAEXXZ)    c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   501 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::createCamera(void)" (?createCamera@BaseApplication@@MAEXXZ)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   502 error LNK2001: unresolved external symbol "protected: virtual void __thiscall BaseApplication::chooseSceneManager(void)" (?chooseSceneManager@BaseApplication@@MAEXXZ)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   503 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::configure(void)" (?configure@BaseApplication@@MAE_NXZ)   c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   504 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall BaseApplication::setup(void)" (?setup@BaseApplication@@MAE_NXZ)   c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   505 error LNK2001: unresolved external symbol "public: virtual void __thiscall BaseApplication::go(void)" (?go@BaseApplication@@UAEXXZ) c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   506 error LNK2001: unresolved external symbol "public: virtual __thiscall BaseApplication::~BaseApplication(void)" (??1BaseApplication@@UAE@XZ) c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   507 error LNK2001: unresolved external symbol "public: __thiscall BaseApplication::BaseApplication(void)" (??0BaseApplication@@QAE@XZ)  c:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\OgreFramework\TutorialApplication.obj OgreFramework
Error   508 error LNK1120: 21 unresolved externals  C:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\Release\OgreFramework.exe OgreFramework

But when I do this it works:

Right click on BaseApplication.cpp file and choosing Compile:

1>------ Build started: Project: OgreFramework, Configuration: Release Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(388,5): warning MSB8028: The intermediate directory (Release\) contains files shared from another project (OgreTest.vcxproj, OgreTiny.vcxproj).  This can lead to incorrect clean and rebuild behavior.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(942,5): warning MSB8027: Two or more files with the name of BaseApplication.cpp will produce outputs to the same location. This can lead to an incorrect build result.  The files involved are aruco\BaseApplication.cpp, BaseApplication.cpp.
1>  BaseApplication.cpp
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Right click on TutorialApplication.cpp file and choosing Compile:

1>------ Build started: Project: OgreFramework, Configuration: Release Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(388,5): warning MSB8028: The intermediate directory (Release\) contains files shared from another project (OgreTest.vcxproj, OgreTiny.vcxproj).  This can lead to incorrect clean and rebuild behavior.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(942,5): warning MSB8027: Two or more files with the name of BaseApplication.cpp will produce outputs to the same location. This can lead to an incorrect build result.  The files involved are aruco\BaseApplication.cpp, BaseApplication.cpp.
1>  TutorialApplication.cpp
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Right click on OgreFramework project and choosing Build

1>------ Build started: Project: OgreFramework, Configuration: Release Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(388,5): warning MSB8028: The intermediate directory (Release\) contains files shared from another project (OgreTest.vcxproj, OgreTiny.vcxproj).  This can lead to incorrect clean and rebuild behavior.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(942,5): warning MSB8027: Two or more files with the name of BaseApplication.cpp will produce outputs to the same location. This can lead to an incorrect build result.  The files involved are aruco\BaseApplication.cpp, BaseApplication.cpp.
1>Release\BaseApplication.obj : warning LNK4042: object specified more than once; extras ignored
1>  Generating code
1>  Finished generating code
1>  OgreFramework.vcxproj -> C:\Users\wakatana\Documents\Visual Studio 2013\Projects\OgreFramework\Release\OgreFramework.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Both *.h files have set Configuration Properties -> General -> Item Type shows: C/C++ header

Both *.cpp files have set Configuration Properties -> General -> Item Type shows: C/C++ compiler

I've tried remove and add *.h files to project as mentioned in this post but I got same errors. Mentioned post also says that those errors can be found in some log but I cannot find it. Thanks

EDIT:

BaseApplication.cpp or TutorialApplication.cpp -> Right click -> Properties -> Configuration Properties -> C/C++ -> Output Files -> Object File Name shows: $(IntDir)

OgreFramework project -> Right click -> Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories -> <edit> -> Macros -> $(IntDir) shows: Debug\

回答1:

Problem solved. I had also included in a solution explorer filter which contained other version of BaseApplication.cpp and BaseApplication.cpp (because I've copied project and not created new one) which caused overwriting my original BaseApplication.cpp and BaseApplication.h. All credit goes to @HansPassant.