• 14
• 12
• 9
• 10
• 9

# Getting ODE to work...

This topic is 3811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, Have not done much coding at all lately so I'm being a bit of a n00b trying to get started with ODE. I'm using MS Visual Studio 2005 and ODE 0.9 with this very simple code to get started (actually there's quite a bit more but I've commented out everything but the stuff below to isolate the probs I'm having with ODE):
#include <windows.h>
#include <ode/ode.h>

extern int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpszArgs,int nWinMode){
// Start up
dInitODE();
// Do something here

// Shut down
dCloseODE();
return 0;
}

But, when the linker runs, I'm getting funky messages:
Error	1	error LNK2005: _malloc already defined in MSVCRTD.lib
(MSVCR80D.dll)	LIBCMTD.lib
Error	2	error LNK2005: _realloc already defined in MSVCRTD.lib
(MSVCR80D.dll)	LIBCMTD.lib
...{3-31 are all similar redefinition errors}
Warning	32	warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of
other libs; use /NODEFAULTLIB:library	VTT
Warning	33	warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of
other libs; use /NODEFAULTLIB:library	VTT
Error	34	error LNK2019: unresolved external symbol "public: void
__thiscall std::_String_base::_Xran(void)const " (?
_Xran@_String_base@std@@QBEXXZ) referenced in function "public: class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > & __thiscall std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >::assign
(class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const &,unsigned int,unsigned int)" (?assign@?
$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z) ode.lib Error 35 error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (? _Xlen@_String_base@std@@QBEXXZ) referenced in function "protected: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Grow(unsigned int,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAE_NI_N@Z)	ode.lib
Error	36	error LNK2019: unresolved external symbol _main referenced in
function ___tmainCRTStartup	LIBCMTD.lib
Error	37	fatal error LNK1120: 3 unresolved externals
C:\Users\Michael\Documents\Visual Studio 2005\Projects\VTT\Debug\VTT.ex
So, in {project} Property Pages -> Configuration Properties -> Linker -> Additional Dependencies, I have added 'ode/debuglib/ode.lib'. Sorry if I'm missing something very, very obvious. There are an awful lot of buttons in MSVC and I'm sort of lost because it has been quite a while since I have used this tool. Thanks for any help! M Ehhh. Also sorry about the width thing...I figured the code box would be fixed width. I will try to put in some linebreaks.[/edit] [Edited by - mearrin69 on October 14, 2007 7:01:49 PM]

##### Share on other sites
While your question does involve ODE - a Physics library, your question has to do more with general programming than Math or Physics.

I'm going to toss this over to General Programming so you're likely to get more responses.

Cheers!

##### Share on other sites
Ah, thanks. You're quite right. I imagine it's just something I'm doing wrong with VS.
M

##### Share on other sites
What's happening here is that part of your code is built to link to the multithreaded DLL runtime libraries, while part of it is built to link to the single-threaded, static non-DLL runtime libraries. You need to configure the solution files so that everything uses the same runtime, and my suggestion is to build for multithreaded DLL.

My suspicion is that ODE is the thing that is built for the single-threaded runtime, though I could be wrong. It could be your code, or some other library that you're linking to. So, to check you need to load up the solution *.sln file, then for each project in the file (well, not all the example/test projects, but the main libraries) go to properties->configuration properties->C/C++->Code Generation. Then look for the Runtime library setting. What you're wanting to select (my recommendation) is "Multi-threaded DLL (/MD)" for release build and "Multi-threaded Debug DLL (/MDd)" for debug build.

Fixup all your solution/project files to use the same settings here, and your "already defined" problems should be solved. I've never had the other std errors when building/linking to ODE, so I feel like solving the runtime library conflict might work all that out as well.

##### Share on other sites
Thanks! I will try this out. I've tried this with basically just the stub code above (i.e. no other libraries) and still get the same problems so I'm guessing it's just whatever project defaults get set when you create a project. Thanks for pointing me at multi- vs single-threading though. I would have had no idea to look there, having never messed with this stuff at all.
M