链接器错误:在静态链接的项目

时间:2015-05-26 19:13:17

标签: templates c++11 linker-errors msvc12

所以,我的团队一直在尝试实现我们自己的shared_ptr实现,这样我们就可以再次在调试模式(VS2013)中成功测试我们的游戏项目。但是,我们遇到了以下错误列表

10>GameLogic.lib(GameLevel.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class LevelRuleset>::operator bool(void)const " (??B?$Handle@VLevelRuleset@@@@QBE_NXZ) referenced in function "public: void __thiscall GameLevel::GameLevelUpdate(float)" (?GameLevelUpdate@GameLevel@@QAEXM@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class LevelRuleset>::operator bool(void)const " (??B?$Handle@VLevelRuleset@@@@QBE_NXZ)
10>GameLogic.lib(GameLogicBehaviors.obj) : error LNK2019: unresolved external symbol "class Handle<class Component> __cdecl static_handle_cast<class Component,class ScaleBehavior>(class Handle<class ScaleBehavior> const &)" (??$static_handle_cast@VComponent@@VScaleBehavior@@@@YA?AV?$Handle@VComponent@@@@ABV?$Handle@VScaleBehavior@@@@@Z) referenced in function "public: void __thiscall GameLogic::AddGrowShrinkPlayer(unsigned long)" (?AddGrowShrinkPlayer@GameLogic@@QAEXK@Z)
10>Graphics.lib(Graphics.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Camera>::operator bool(void)const " (??B?$Handle@VCamera@@@@QBE_NXZ) referenced in function "private: void __thiscall GraphicsSystem::LoadGeneratedObjects(void)" (?LoadGeneratedObjects@GraphicsSystem@@AAEXXZ)
10>Graphics.lib(AntTweakSys.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class Camera>::operator bool(void)const " (??B?$Handle@VCamera@@@@QBE_NXZ)
10>Graphics.lib(DX11.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class Camera>::operator bool(void)const " (??B?$Handle@VCamera@@@@QBE_NXZ)
10>Graphics.lib(Graphics.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Debug>::operator bool(void)const " (??B?$Handle@VDebug@@@@QBE_NXZ) referenced in function "private: void __thiscall GraphicsSystem::LoadGeneratedObjects(void)" (?LoadGeneratedObjects@GraphicsSystem@@AAEXXZ)
10>Graphics.lib(AntTweakSys.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class Debug>::operator bool(void)const " (??B?$Handle@VDebug@@@@QBE_NXZ)
10>Graphics.lib(GFXMessageHandler.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class Debug>::operator bool(void)const " (??B?$Handle@VDebug@@@@QBE_NXZ)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Group>::operator bool(void)const " (??B?$Handle@VGroup@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class RigidBody>::operator bool(void)const " (??B?$Handle@VRigidBody@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(DX11.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class RigidBody>::operator bool(void)const " (??B?$Handle@VRigidBody@@@@QBE_NXZ)
10>Physics.lib(Physics.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class RigidBody>::operator bool(void)const " (??B?$Handle@VRigidBody@@@@QBE_NXZ)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Collider>::operator bool(void)const " (??B?$Handle@VCollider@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(DX11.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class Collider>::operator bool(void)const " (??B?$Handle@VCollider@@@@QBE_NXZ)
10>Physics.lib(Physics.obj) : error LNK2001: unresolved external symbol "public: __thiscall Handle<class Collider>::operator bool(void)const " (??B?$Handle@VCollider@@@@QBE_NXZ)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Controller>::operator bool(void)const " (??B?$Handle@VController@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Spawner>::operator bool(void)const " (??B?$Handle@VSpawner@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class PlayerStats>::operator bool(void)const " (??B?$Handle@VPlayerStats@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Gun>::operator bool(void)const " (??B?$Handle@VGun@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Owner>::operator bool(void)const " (??B?$Handle@VOwner@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class StatModifier>::operator bool(void)const " (??B?$Handle@VStatModifier@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Graphics.lib(AntTweakSys.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class LifeTime>::operator bool(void)const " (??B?$Handle@VLifeTime@@@@QBE_NXZ) referenced in function "private: static void __stdcall AntTweakSystem::AddObjectBar(void *)" (?AddObjectBar@AntTweakSystem@@CGXPAX@Z)
10>Input.lib(Input.obj) : error LNK2019: unresolved external symbol _SDL_GetError referenced in function "public: virtual void __thiscall InputSystem::Initialize(void)" (?Initialize@InputSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2001: unresolved external symbol _SDL_GetError
10>Input.lib(Input.obj) : error LNK2019: unresolved external symbol _SDL_PollEvent referenced in function "private: void __thiscall InputSystem::HandleEvents(void)" (?HandleEvents@InputSystem@@AAEXXZ)
10>Input.lib(Input.obj) : error LNK2019: unresolved external symbol _SDL_EventState referenced in function "private: void __thiscall InputSystem::HandleEvents(void)" (?HandleEvents@InputSystem@@AAEXXZ)
10>Input.lib(Input.obj) : error LNK2019: unresolved external symbol _SDL_Init referenced in function "public: virtual void __thiscall InputSystem::Initialize(void)" (?Initialize@InputSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2001: unresolved external symbol _SDL_Init
10>Input.lib(Input.obj) : error LNK2019: unresolved external symbol _SDL_QuitSubSystem referenced in function "public: virtual int __thiscall InputSystem::Release(void)" (?Release@InputSystem@@UAEHXZ)
10>Windows.lib(Windows.obj) : error LNK2001: unresolved external symbol _SDL_QuitSubSystem
10>Input.lib(Input.obj) : error LNK2019: unresolved external symbol "public: __thiscall Handle<class Component>::operator bool(void)const " (??B?$Handle@VComponent@@@@QBE_NXZ) referenced in function "private: void __thiscall InputSystem::HandleMessage(void)" (?HandleMessage@InputSystem@@AAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_RWFromFile referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_MapRGB referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_FreeSurface referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_LoadBMP_RW referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_FillRect referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_CreateWindow referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_SetWindowIcon referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_GetWindowSize referenced in function "public: virtual void __thiscall WindowSystem::TransmitMessage(class std::shared_ptr<class Message>)" (?TransmitMessage@WindowSystem@@UAEXV?$shared_ptr@VMessage@@@std@@@Z)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_MinimizeWindow referenced in function "public: virtual void __thiscall WindowSystem::TransmitMessage(class std::shared_ptr<class Message>)" (?TransmitMessage@WindowSystem@@UAEXV?$shared_ptr@VMessage@@@std@@@Z)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_GetWindowSurface referenced in function "public: virtual void __thiscall WindowSystem::Initialize(void)" (?Initialize@WindowSystem@@UAEXXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_DestroyWindow referenced in function "public: virtual int __thiscall WindowSystem::Release(void)" (?Release@WindowSystem@@UAEHXZ)
10>Windows.lib(Windows.obj) : error LNK2019: unresolved external symbol _SDL_ShowSimpleMessageBox referenced in function "private: void __thiscall WindowSystem::ErrorPopUp(class std::shared_ptr<class ErrorMessage> const &)" (?ErrorPopUp@WindowSystem@@AAEXABV?$shared_ptr@VErrorMessage@@@std@@@Z)
10>A:\Mercurial\CodeFish\Build\AntTweakDebugWin32\Game.exe : fatal error LNK1120: 32 unresolved externals

目前我们担心的主要问题是Handle类中的操作员bool的LNK2019。作为参考,这里是完整的课程:

template <class TYPE>
class Handle;

template <class TYPE_TO_CAST_TO, class TYPE_TO_CAST_FROM>
Handle<TYPE_TO_CAST_TO> static_handle_cast(Handle<TYPE_TO_CAST_FROM> const& subject);

template <class TYPE>
class Handle : public HandleRegistrar
{
  // friend all Handles so that we may convert them
  template<class U> friend class Handle;
  template<class T, class U> friend Handle<T> static_handle_cast(Handle<U> const& subject);

  private:
    bool m_weak;
    int* m_ref_count;
    TYPE** m_ptr;

  public:
    void destruct(void);
    int use_count(void) const;
    bool expired(void) const;
    void swap(Handle<TYPE>& rhs);
    TYPE* get(void);
    TYPE* get(void) const;
    template<typename TYPE2> Handle<TYPE>& operator=(const Handle<TYPE2>& rhs);
    Handle<TYPE>& operator=(const Handle<TYPE>& rhs);
    template<typename TYPE2> Handle<TYPE>& operator=(TYPE2* rhs);
    TYPE* operator->(void);
    TYPE* operator->(void) const;
    TYPE& operator*(void);
    TYPE& operator*(void) const;
    bool operator==(const Handle<TYPE>& rhs);
    void operator%(Handle<TYPE>& rhs);
    operator bool(void) const;

  public:
    ~Handle(void);
    Handle(const Handle<TYPE>& rhs, bool weak = false);
    template<typename TYPE2> Handle(const Handle<TYPE2>& rhs, bool weak = false);
    Handle(TYPE& object_to_point_at, bool weak = false);
    Handle(TYPE*&& pointer_to_object, bool weak = false);
    Handle(void);
 };

我们在Handle类的.cpp文件中没有任何实现,它完全在头文件中实现。我一直在寻找这个问题的解决方案一段时间,并通过所以看了很多关于这个问题的LNK2019文章,希望能找到关于这个问题的任何内容...对可能发生的事情的任何帮助或洞察非常感谢。我们的游戏项目中有很多内容,所以如果需要更多信息,我会提供它。

关于项目的事情:
- 静态链接,代码分布在11个库中 - 使用预编译头文件。

0 个答案:

没有答案