Problem linking Newton in my project.

Darkness

03-02-2006 02:07:36

I have Newton and OgreNewt installed, but for some reason when I try to create a World object, I get a link error. I have Newton.lib and OgreNewt_Main.lib included. Is there something else I need to add?

Here's the link error I get:


Linking...
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonMaterialGetDefaultGroupID
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonWorldSetUserData
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonCreate
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonUpdate
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonGetTimeStep
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonSetWorldSize
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonBodyGetUserData
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonWorldGetUserData
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonBodyGetWorld
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonDestroy
OgreNewt_Main.lib(OgreNewt_World.obj) : error LNK2001: unresolved external symbol __imp__NewtonSetBodyLeaveWorldEvent
OgreNewt_Main.lib(OgreNewt_MaterialID.obj) : error LNK2001: unresolved external symbol __imp__NewtonMaterialCreateGroupID
D:\PROJECTS\BCO\Release\BCO.exe : fatal error LNK1120: 12 unresolved externals
Build log was saved at "file://d:\PROJECTS\BCO\BCO\Release\BuildLog.htm"
BCO - 13 error(s), 3 warning(s)


Thanks in advance.


-Darkness

walaber

03-02-2006 05:04:48

in your linker settings you need to point it to OgreNewt/OgreNewt_Main/lib
and make sure you include "OgreMain.lib" in the list of libraries.

Darkness

03-02-2006 07:17:31

I have both of those link locations and libs. I have OgreNewt_Main.lib and OgreMain.lib. If I don't include the OgreNewt stuff, my project compiles and runs fine (it's an Ogre project). Not sure what else I could be missing, but I know I didn't compile the DLL files. Seems an odd problem, but I'm not sure what could be causing it.


-Darkness


P.S. My path is OgreNewt_Main/lib/release. There's nothing in the base /lib directory.

haffax

03-02-2006 08:18:17

You don't seem to be linking to your Newton.lib. Make sure you do. If you don't find the error, paste your buildlog.htm file.

walaber

03-02-2006 15:50:26

ahah. good catch haffax.

make sure you inlucde "newtonsdk/sdk/dll" and "newton.lib"

Darkness

03-02-2006 17:41:20

Heh, heh. I do have Newton.lib included. However, here's the kicker...there are a bunch of different Newton directories. There's the dll directory, then lib_mt, lib_mt_double, lib_st, and lib_st_double. I have it grabbing Newton.lib from the lib_mt directory. Unless there's some trouble with that, then I have everything I should need linked. I'll dig up the build log in a bit. Since it didn't work, I just turned that stuff off and started working on something else in the meantime.


-Darkness

OvermindDL1

04-02-2006 00:21:02

Walaber, for the VC (any version) builds, you should add the pragma that autolinks all necessary libs (assuming they are in the compiler lib paths somewhere) for OgreNewt and Newton. Not hard to do, and it saves forgetting to do a link eveytime I, er... we, make a new project with it. :)

haffax

04-02-2006 00:51:19

Personally I don't like #pragma comment at all. It is too inflexible and not obvious. Project files are the place to define the libs and it is neither hard nor time intensive to add a lib file to the additional dependencies.

Darkness

04-02-2006 02:39:26

Honestly, it doesn't matter to me. I usually include whatever lib paths I have for each new SDK I add. It's just habit now. That said, I'm not sure why OgreNewt is giving me grief. Everything built fine and so I don't understand why there would be a linking error. Does this have to do with the way the libs were built in the first place, or is there something else going on?


-Darkness


P.S.- Here's my buildlog...
http://www.rafb.net/paste/results/DCWzh442.htm

This time I even drug the Newton.dll into my project directory and I'm still getting the same link errors. I wonder if there was an issue when I built the .lib in the first place...

haffax

04-02-2006 10:53:20

The pastbin-link doesn't work. And DLLs are never needed for linking, LIBs are, and you don't have to drag them around, just include the directory where it resides to your additional directories path for your linker. Moving/copying files around is a sure way to doom, since one or the other time you don't know anymore what lib/h/whatever file came from where and everything is just a mess.

Darkness

04-02-2006 16:54:36

Let me try this again...

http://www.rafb.net/paste/results/DCWzh442.html


Yeah, I know about libs and how to link them. I'm just grasping for straws because everything is linked.

Currently, I have these libs linked:

Newton.lib
OgreNewt_Main.lib
OgreMain.lib

From my understanding on how this works, those are the libs I need to link to. All of the directories are there, too.

Like I said, I wonder if something went wrong when the libs were compiled. I can't think of any other reason why it wouldn't link.


-Darkness

haffax

04-02-2006 23:39:15

All of the directories are there, too.
What all directories? Which of the many Newton.libs are you linking here, do you maybe have multiple directores in your global library path/project dependency path that contain different versions of Newton.lib?

OvermindDL1

05-02-2006 04:13:41

All of the directories are there, too.
What all directories? Which of the many Newton.libs are you linking here, do you maybe have multiple directores in your global library path/project dependency path that contain different versions of Newton.lib?

Have to admit, that does make it interesting to choose though. Newton makes quite a few different libraries that all have the same name. Boost's naming scheme for those would be far better, as Ogre uses.

Darkness

05-02-2006 05:21:32

What all directories? Which of the many Newton.libs are you linking here, do you maybe have multiple directores in your global library path/project dependency path that contain different versions of Newton.lib?

I am using the Newton.lib in Newton/lib/lib_mt directory and OgreNewt_Main/lib/release for the OgreNewt directory.

I only have one directory pointing to Newton.lib.

As I stated before, my project works great until I add in the OgreNewt/Newton lines of code. The Ogre libs work fine as my project will run without the physics stuff. I'm going to to try to recompile the OgreNewt stuff when I get home. Maybe something went wrong when it was compiled.


-Darkness

walaber

05-02-2006 05:31:41

OgreNewt is intended (by default) to use the DLL version of newton. if you want to use the static lib (which you do), you need to recompile OgreNewt, with the preprocesor define NEWTON_USE_LIB (i think that's right, look at newton.h to confirm).

then you will not need to link to Newton.lib in your own project, because it will be compiled into the OgreNewt_Main.lib library.

on the other hand, if you just switch to the newton/sdk/dll version, it will work fine as-is.

Darkness

05-02-2006 06:44:48

Okay. I'll give that a shot when I get home. I figured it'd want the DLL, but I guess something got all wonky when it got compiled. Thanks for the tip...I'll let you know how it works out tomorrow.


-Darkness

walaber

05-02-2006 18:34:26

the problem is that OgreNewt was compiled againts the DLL version (sdk/dll), but your application is trying to link to the static version (lib_mt). if you link to the same one as OgreNewt it will compile fine.

or if you want the static version, you need to change OgreNewt.

Darkness

06-02-2006 20:42:17

I went ahead and tried to rebuild the OgreNewt libs again, and I'm still getting the same kind of error with the same symbols. It's looking for some sort of external symbols and they're not included anywhere.

When building OgreNewt, do I have to change something fundamental about the solution in order to get it to look at the Newton.lib file? I changed the directory, but I didn't see where it was looking for Newton.lib.

Heh, not sure why I'm having such a problem getting this to work...and I apologize for the trouble.


-Darkness

walaber

06-02-2006 21:53:09

please clarify for me what you want to do:

1) Use OgreNewt as standard, which uses the DLL version of Newton.
2) Use OgreNewt with the static library version of newton.

Darkness

07-02-2006 09:00:44

I want to use whichever is going to work. I have no problems using the .DLL, and I have no problems using the static lib. The goal of this is to have it portable with the client. Having a static lib would be good for this. I'll go with whatever you recommend. It's your show, I'm just a spectator. :)


-Darkness

walaber

07-02-2006 15:40:59

in that case the simplest solution it to leave OgreNewt alone, and change your linker directory in your app to newton/sdk/dll/, not lib_mt.

Darkness

07-02-2006 17:49:20

I went back and made a link to the Newton/sdk/dll directory. I also removed the preprocessor directive you mentioned earlier. I compiled. Everything compiled correctly. When I tried to use it in my project, I get the same error. It's not linking those classes. I'm thinking of deleting everything and starting all over, because something is messed up somewhere. I don't see anyone else having this problem. I followed the instructions on the wiki except my directories are all in differnt places. I made the necessary adjustments to the directories yet it's still giving me the same error.

The other thing I want to know is if I use the .dll Newton, will that mean I'll have to leave the directory structure intact when distributing the client? Or can I place the .dll in the root directory and it'll work?

Anyone have any other ideas?


-Darkness

walaber

07-02-2006 18:50:25

okay, try starting over. when using the .dll version, you just need newton.dll in with all your other ogre.dll's, in the directory with your .exe file.

Darkness

08-02-2006 20:32:25

Alright, I have a fresh copy of OgreNewt. What do I need to do now? I haven't compiled or anything, so I want to make sure I have everything in place before I screw anything up. Heh, heh.


-Darkness

walaber

08-02-2006 23:13:01

if you are using MSVC, just compile the solution out of the box, it should work fine.

then when you work on your own project, look at the settings of the various OgreNewt demos, and make sure you project is set up similarly.

Darkness

09-02-2006 09:26:53

Alright. Did a clean compile...same error when I link in my project. Just for shizz and giggles, I decided to try to compile the demos. I get the same error. Not sure what else is left to try, but I'm all out of options.


-Darkness

walaber

09-02-2006 16:55:14

maybe you have an outdated version of newton itself that is getting linked to, or something?

Darkness

11-02-2006 17:46:36

I'm using whatever version of Newton they have on their site. I just downloaded the SDK a few days ago. Would the fact that I'm using VC8 Express matter? Or is there another project option that I should have selected in order to get it to link properly with the Newton files? Also, if it builds properly, wouldn't that mean it's hitting the Newton files properly?


-Darkness

walaber

11-02-2006 18:32:06

well OgreNewt_Main compiles to a static library, so it doesn't get linked with newton.lib, that happens in the end project.

I use VC8 Express, so I don't see why you should be having problems.

of course with Ogre app you need to make sure you compile in "multithread DLL" mode, but that' about it...

Darkness

12-02-2006 06:07:50

Strange. I have all of those thing set. So I'm not sure what's causing it. I thought it was my project, but the demos won't even compile. So don't think that's it. I'm using Win2k. It's kind of a long shot, but could that have anything to do with it? I doubt it since everything else works fine. Just OgreNewt and Newton....

Is it possible for you to send me a test static lib that works? I wonder if the connection is to the Newton libs or .dlls. I'm reaching for straws now, but as I mentioned before...I"m all out of ideas.


-Darkness

galundin2

10-03-2006 16:35:57

I know this forum is for Ogre, but I've got a sort of similar problem trying to use Newton with Irrlicht in VS7.1... I'm trying to compile an unmodified tutorial project. I've got the proper include and lib directories set, but some of the Newton references come up as undeclared identifiers. And complaints of incorrect parameters seem suspicious of a version conflict... Any clues? Did darkness ever get his problem resolved?

c:\projects\Game2\code\game.cpp(182) : error C2065: 'NewtonMaterialGetContactUserData' : undeclared identifier
c:\projects\Game2\code\game.cpp(182) : error C2440: '=' : cannot convert from ''unknown-type'' to 'SPECIAL_EFFECT *'
c:\projects\Game2\code\game.cpp(327) : error C2065: 'NewtonBallGetUserData' : undeclared identifier
c:\projects\Game2\code\game.cpp(434) : error C2065: 'NewtonSliderGetUserData' : undeclared identifier
c:\projects\Game2\code\game.cpp(434) : error C2440: '=' : cannot convert from ''unknown-type'' to 'SliderContrlStruct *'
c:\projects\Game2\code\game.cpp(444) : error C2440: '=' : cannot convert from ''unknown-type'' to 'SliderContrlStruct *'
c:\projects\Game2\code\game.cpp(629) : error C2065: 'NewtonBallSetUserData' : undeclared identifier
c:\projects\Game2\code\game.cpp(632) : error C2065: 'NewtonBallSetDestructor' : undeclared identifier
c:\projects\Game2\code\game.cpp(758) : error C2065: 'NewtonSliderSetUserData' : undeclared identifier
c:\projects\Game2\code\game.cpp(759) : error C2065: 'NewtonSliderSetDestructor' : undeclared identifier
c:\projects\Game2\code\game.cpp(1256) : error C2664: 'NewtonBodyAddBuoyancyForce' : cannot convert parameter 6 from 'void (void *,const float *,float *)' to 'NewtonGetBuoyancyPlane'
None of the functions with this name in scope match the target type
c:\projects\Game2\code\game.cpp(1542) : error C2660: 'NewtonRagDollAddBone' : function does not take 6 parameters

walaber

10-03-2006 17:05:08

newton has changed since the tutorial you downloaded. most of those functions are now "common" joint functions like "NewtonJointSetDestructor" instead of the per-joint type versions. have a look through newton.h, you should be able to find the new version of the functions.