Linker error that only occurs with the Havok SDK

486 Views Asked by At

I'm working with Havok Physics and when I was doing some learning and practicing I had a project just for Havok. Now I want to include it into my game but I get these errors.

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

These errors appear for every file so for Somefile.obj Somefile2.obj Somefile3.obj etc.

I figured I get this error because the way I have files included into each other because when I include this into a cpp file unlike including it into my header file which gets included into all of my other header files then it works. This error only happens with the Havok SDK. Other includes like DirectX SDK and FBX SDK work fine if I include them this way.

To help you, this is how I have my files

I have an Include.h file which contains all my class declatations, includes for things like and , and includes for every single other header file in my project.

These are the Havoc headers I've included in my Include.h file.

#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>

Then all my other header files include Include.h and those files have my classes that I declared in them.

Hopefully this gives you enough information for you to help me with this problem and thank you.

1

There are 1 best solutions below

1
On

Have a look at this tutorial series and the accompanying github repo. http://mmmovania.blogspot.com/2014/03/havok-physics-engine-tutorial-series.html https://github.com/mmmovania/HavokPhysicsTutorials

Hope it helps, Mobeen