我正在和Havok物理合作,当我在做一些学习和练习的时候,我有一个专门为Havok做的项目。现在我想把它加入到我的游戏中,但是我得到了这些错误。
Somefile.obj : error LNK2005: "public: static class hkTypeInfo const * const * const hkBuiltinTypeRegistry::StaticLinkedTypeInfos" (?StaticLinkedTypeInfos@hkBuiltinTypeRegistry@@2QBQBVhkTypeInfo@@B) already defined in
Somefile.obj : error LNK2005: "public: static class hkClass const * const * const hkBuiltinTypeRegistry::StaticLinkedClasses" (?StaticLinkedClasses@hkBuiltinTypeRegistry@@2QBQBVhkClass@@B) already defined in
Somefile.obj : error LNK2005: "char const * const HK_PHYSICS_2012_KEYCODE" (?HK_PHYSICS_2012_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "char const * const HK_PHYSICS_KEYCODE" (?HK_PHYSICS_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "char const * const HK_ANIMATION_KEYCODE" (?HK_ANIMATION_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "char const * const HK_BEHAVIOR_KEYCODE" (?HK_BEHAVIOR_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "char const * const HK_CLOTH_KEYCODE" (?HK_CLOTH_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "char const * const HK_DESTRUCTION_2012_KEYCODE" (?HK_DESTRUCTION_2012_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "char const * const HK_DESTRUCTION_KEYCODE" (?HK_DESTRUCTION_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "char const * const HK_AI_KEYCODE" (?HK_AI_KEYCODE@@3QBDB) already defined in
Somefile.obj : error LNK2005: "public: static struct hkVersionRegistry::Updater const * * hkVersionRegistry::StaticLinkedUpdaters" (?StaticLinkedUpdaters@hkVersionRegistry@@2PAPBUUpdater@1@A) already defined in
Somefile.obj : error LNK2005: "public: static class hkStaticClassNameRegistry const * * hkVersionRegistry::StaticLinkedClassRegistries" (?StaticLinkedClassRegistries@hkVersionRegistry@@2PAPBVhkStaticClassNameRegistry@@A) already defined in
Somefile.obj : error LNK2005: "void __cdecl hkProductFeatures::initialize(void)" (?initialize@hkProductFeatures@@YAXXZ) already defined in这些错误出现在每个文件中,比如Somefile.obj、Somefile2.obj、Somefile3.obj等等。
我想我得到这个错误是因为我将文件包含在彼此中的方式,因为当我将它包含到cpp文件中时,不同于将它包含到我的头文件中,它会被包含到我的所有其他头文件中,然后它就可以工作了。此错误仅发生在Havok SDK中。其他包括,如DirectX SDK和FBX SDK工作正常,如果我以这种方式包含它们。
为了帮助你,这就是我的文件
我有一个Include.h文件,其中包含我所有的类描述,包括和之类的内容,并包含项目中每个其他头文件的内容。
这些是我在Include.h文件中包含的Havoc头文件。
#include <Common/Base/keycode.cxx>
#include <Common/Base/Config/hkProductFeatures.cxx>
#include <Common/Base/hkBase.h>
#include <Common/Base/System/hkBaseSystem.h>
#include <Common/Base/System/Error/hkDefaultError.h>
#include <Common/Base/Memory/System/hkMemorySystem.h>
#include <Common/Base/Memory/System/Util/hkMemoryInitUtil.h>
#include <Common/Base/Memory/Allocator/Malloc/hkMallocAllocator.h>
#include <Common/Base/Thread/Job/ThreadPool/Cpu/hkCpuJobThreadPool.h>
#include <Physics2012/Dynamics/World/hkpWorld.h>
#include <Physics2012/Collide/Dispatch/hkpAgentRegisterUtil.h>
#include <Physics2012\Collide\Shape\Convex\Box\hkpBoxShape.h>
#include <Physics2012\Dynamics\Entity\hkpRigidBody.h>
#include <Physics2012\Utilities\Dynamics\Inertia\hkpInertiaTensorComputer.h>
#include <Physics2012\Dynamics\World\hkpSimulationIsland.h>然后,我的所有其他头文件都包含Include.h,并且这些文件包含我在其中声明的类。
希望这篇文章能给你足够的信息来帮助我解决这个问题,谢谢你。
发布于 2014-07-02 14:16:09
请看一下本系列教程和附带的github存储库。http://mmmovania.blogspot.com/2014/03/havok-physics-engine-tutorial-series.html https://github.com/mmmovania/HavokPhysicsTutorials
希望能帮上忙,莫贝
https://stackoverflow.com/questions/24066691
复制相似问题