Linking Issues

Linking Issues

This is my first here. I'm using Visual Studio 2008 C++ and Direct X 9 (if that's important), I'm trying to get started with Havok , but I don't know how. I downloaded it, and tried to #include the headers and libraries the way someone I know did, but I get all kinds of weird errors (226 in total). Errors like:

syntax error: 'constant'

function returns function

static member 'operator new' has no formal parameters

And they are all inside havok's headers and stuff. Did I download the wrong version or something? I clicked on the Havok Physics and Havok Animation SDKs for Programmers (2010.1.0, VS2008) download link on their website, is that the right one? Am I not including everything I need to, or am I forgetting something? This is the include code:

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#define HK_CLASSES_FILE

#include

#pragma comment ( lib, "hkBase.lib" )

#pragma comment ( lib, "hkInternal.lib" )

#pragma comment ( lib, "hkGeometryUtilities.lib" )

#pragma comment ( lib, "hkVisualize.lib" )

#pragma comment ( lib, "hkSerialize.lib" )

#pragma comment ( lib, "hkSceneData.lib" )

#pragma comment ( lib, "hkCompat.lib" )

#pragma comment ( lib, "hkpConstraintSolver.lib" )

#pragma comment ( lib, "hkpCollide.lib" )

#pragma comment ( lib, "hkpDynamics.lib" )

#pragma comment ( lib, "hkpInternal.lib" )

#pragma comment ( lib, "hkpUtilities.lib" )

#pragma comment ( lib, "VdbClient.lib" )

And I set the path to the Source folder in Havok as an additional include directory so it knows where to look for the files. I looked around in the Documentation, but couldn't find anything (I probably just don't know where to look, though).

I've heard that Havok is also a good way to add raycast collisions in games.Is there a tutorial that shows how to perform raycast collisions so I can make a first person shooter camera follow terrain and stuff? Thanks for any help.

12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hello Kryo,
Yes, you have downloaded the right thing,

First of all, the most important are first 5-6 error messages, others probably wont make sense...
so tell usexactly what they are.

Secondly, a good way to startis to copy everything standalone demo includes - Demo\StandAloneDemos\ConsoleExampleMt
Does it link and compile okay for you?

Good luck with it!

P.S.
'static member 'operator new' has no formal parameters'
might be related to operator overloading your code does, I think I run into similiar problem a long time ago.

These are the first 6 or so errors I get:

1>c:\program files (x86)\havok_physics_animation_201010_pc_xs_win32_vs2008_keycode_perpetual_20100811\hk2010_1_0_r1\source\common\base\memory\allocator\hkmemoryallocator.h(38) : error C2059: syntax error : 'constant'

1>c:\program files (x86)\havok_physics_animation_201010_pc_xs_win32_vs2008_keycode_perpetual_20100811\hk2010_1_0_r1\source\common\base\memory\allocator\hkmemoryallocator.h(38) : error C2091: function returns function

1>c:\program files (x86)\havok_physics_animation_201010_pc_xs_win32_vs2008_keycode_perpetual_20100811\hk2010_1_0_r1\source\common\base\memory\allocator\hkmemoryallocator.h(38) : error C2802: static member 'operator new' has no formal parameters

1>c:\program files (x86)\havok_physics_animation_201010_pc_xs_win32_vs2008_keycode_perpetual_20100811\hk2010_1_0_r1\source\common\base\memory\allocator\hkmemoryallocator.h(38) : error C2333: 'hkMemoryAllocator::operator new' : error in function declaration; skipping function body

1>c:\program files (x86)\havok_physics_animation_201010_pc_xs_win32_vs2008_keycode_perpetual_20100811\hk2010_1_0_r1\source\common\base\memory\allocator\lifo\hklifoallocator.h(22) : error C2059: syntax error : 'constant'

The demo compiled, so I must not be doing something right, I'll probably just take a look at the demo.

I guess its becauseyou haven't included to KeyCode file - yep, see what the demo includes carefully.

Include to KeyCode file? What does that mean, I'm a big noob at this stuff XD

I've reduced my linking errors by half (still making it 113 errors) by putting the include code ina seperate header file and including it in my engine's .cpp file instead of putting it in my engines .h file which is already included in my engine .cpp. I think this is because the engine header gets included in the engine .cpp file and the main.cpp file, but the seperate header file only gets included once. Why would the errors repeat like that (which I assume is happening since my errors were reduce exactly but half)? Thanks.

Sorry, typing error, I meant to say 'include THE KeyCode file'.

You need to include this -

// Keycode
#include

// Classlists
#undef HK_FEATURE_PRODUCT_AI
#undef HK_FEATURE_PRODUCT_ANIMATION
#undef HK_FEATURE_PRODUCT_CLOTH
#undef HK_FEATURE_PRODUCT_DESTRUCTION
#undef HK_FEATURE_PRODUCT_BEHAVIOR
#define HK_EXCLUDE_LIBRARY_hkgpConvexDecomposition
#define HK_FEATURE_REFLECTION_PHYSICS
#define HK_CLASSES_FILE
#include

(consult ConsoleDemo what exactly this list should be!)

in ONE of your CPP's.

As for .h / .cpp policy...

[your main.h] <- only include Havok headers that describe classes met in this header
[your main.cpp] <- include main.h, Keycode stuff, and Havok headers that you need (which you havent included to main.h)

I just realized that I needed to set the debug_multithreaded_dll as an additional library dependency, so I did that. I included the keycode file, and it still doesn't work (still gives 113 errors). I included the BuildLog which shows all the errors. Here's my include code

// Math and base include

#include

#include

#include

#include

#include

#include

#include

// Dynamics includes

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

// Visual Debugger includes

#include

#include

// Keycode

#include

#if !defined HK_FEATURE_PRODUCT_PHYSICS

#error Physics is needed to build this demo. It is included in the common package for reference only.

#endif

// This excludes libraries that are not going to be linked

// from the project configuration, even if the keycodes are

// present

#undef HK_FEATURE_PRODUCT_AI

#undef HK_FEATURE_PRODUCT_ANIMATION

#undef HK_FEATURE_PRODUCT_CLOTH

#undef HK_FEATURE_PRODUCT_DESTRUCTION

#undef HK_FEATURE_PRODUCT_BEHAVIOR

#define HK_EXCLUDE_LIBRARY_hkgpConvexDecomposition

#define HK_FEATURE_REFLECTION_PHYSICS

#define HK_CLASSES_FILE

#include

Attachments: 

AttachmentSize
Download BuildLog.htm62.63 KB

Oh well, Im certain now that its due to some syntax error like missing endingbracket, or missing ';' BEFORE '#include havok stuff' lines. Its hard to tell what it is without seeing all your code..

You include Havok the correct way.
Once again, I suggest you to start investigating standalone Console Demo.

P.S. debug_multithreaded_dll as library dependency may have removed LINK errors, but at this point all you get are COMPILE errors.

All the include code is in the engine's .cpp. The only code above the include code is this (which all worked right before I started trying to including Havok)

#include "KryDX2.h"

#include "Camera.h"

#include "CXFile.h"

#include "XFileEntity.h"

#include "XFileStatic.h"

I looked at the standalone console thing, but I can't find what I'm doing wrong (I did find out about the library dependency thing, though).

Try removing all your includes (KryDX2.h etc) one by one.
Dont you use namespaces? Do you use default VS C++ compiler in your project?

I suppose the errors are related either to your engine's headers or your project settings.

I found the problem, one of the headers included in KryDX2.h had a strange block of code (I didn't really know about since I copied and pasted it) that caused the errors, it was this:

#if defined(DEBUG) | defined(_DEBUG)

#include

#define new new(_NORMAL_BLOCK,__FILE__, __LINE__)

#endif

I got a warning though, what doesit mean, how bad is it?

1>c:\program files (x86)\havok_physics_animation_201010_pc_xs_win32_vs2008_keycode_perpetual_20100811\hk2010_1_0_r1\source\common\base\container\string\hkstring.h(36) : warning C4995: 'sprintf': name was marked as #pragma deprecated

Thanks for your help so far :)

Hi,This warning is generated because the visual studio crt now consider sprintf to be deprecated and replaced by a new secure version called sprinf_s that ensure there is no buffer overflow.You can safely ignore this warning.Vincent

Leave a Comment

Please sign in to add a comment. Not a member? Join today