Bugs in ODE system (with fixes)

Hmm, this means that the library wasn’t built with interrogate_module. There are two parts to interrogate: interrogate itself, which generates all of the API wrappers, and interrogate_module, which generates the additional wrappers that make the library loadable as a Python module. We normally run interrogate on each of the component libraries, and then interrogate_module on the meta library.

David

Ah, thanks for the really quick reply. Makepanda seemed to have skipped it since it appeared to be already done. I’ll try it again.

b[/b] On linux, everything works fine now. On windows too, up to the interrogate step. I’m getting this error:

built/bin/interrogate blah blah yadda yadda
*** Error in /z/projects/panda3d/thirdparty/win-libs-vc8/ode/include/ode/config.h near line 62, column 4:
"Need some help identifying the platform!"

This is the corresponding bit of code:

#elif defined(_MSC_VER) || defined(__CYGWIN32__) || defined(__MINGW32__)
  #define ODE_PLATFORM_WINDOWS
#elif defined(__linux__)
  #define ODE_PLATFORM_LINUX
#elif defined(__APPLE__) && defined(__MACH__)
  #define ODE_PLATFORM_OSX
#else
  #error "Need some help identifying the platform!"
#endif

So, I added -D_MSC_VER to the default interrogate options on windows. Not to the compiler options, since that seems to cause a lot of trouble.
That makes it fine, but is this isn’t this too dangerous to do? Or should I make it -D_MSC_VER=1400 (1400 is the code for VC2005)?

b[/b] I’m getting these linker errors on windows:

link /nologo /NOD:MFC80.LIB /NOD:LIBCI.LIB /NOD:MSVCRTD.LIB /DEBUG  /nod:libc /nod:libcmtd /nod:atlthunk /DLL /MAP /MAPINFO:EXPORTS /FIXED:NO /OPT:REF /STACK:4194304 /INCREMENTAL:NO  /OUT:built/bin/libpandaode.dll /IMPLIB:built/lib/libpandaode.lib /LIBPATH:"thirdparty/win-python/libs" built/tmp/pandaode_pandaode.obj built/tmp/libpandaode_module.obj built/tmp/pode_composite1.obj built/tmp/pode_composite2.obj built/tmp/pode_composite3.obj built/tmp/libpandaode_igate.obj built/lib/libpanda.lib built/lib/libpandaexpress.lib built/lib/libp3dtool.lib built/lib/libp3dtoolconfig.lib thirdparty/win-libs-vc8/ode/lib/ode.lib
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in ode.lib(convex.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in ode.lib(convex.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in ode.lib(convex.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall std::basic_string<
char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<ch
ar,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_s
tring<char,struct std::char_traits<char>,class std::allocator<char> > const &)"
(??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) a
lready defined in ode.lib(convex.obj)
LIBCMT.lib(crtheap.obj) : error LNK2005: __malloc_crt already defined in MSVCRT.
lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(realloc.obj) : error LNK2005: _realloc already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter_noinfo already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj) : error LNK2005: __encoded_null already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRT.lib(MSVCR80.dll)
   Creating library built/lib/libpandaode.lib and object built/lib/libpandaode.e
xp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; us
e /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; us
e /NODEFAULTLIB:library
ode.lib(error.obj) : error LNK2019: unresolved external symbol __imp__MessageBox
A@16 referenced in function _dError
ode.lib(convex.obj) : 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_t
raits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,str
uct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsi
gned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@
QAEAAV12@II@Z)
ode.lib(convex.obj) : 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,struc
t 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
)
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main reference
d in function ___tmainCRTStartup
built/bin/libpandaode.dll : fatal error LNK1120: 4 unresolved externals

Sorry to be a bother again, but these errors tell me nothing. It’s been months since I’ve booted into windows, I barely compile stuff on windows.

It’s not as dangerous as you might think, since interrogate isn’t really a compiler. It just needs to be able to parse the code in order to figure out what the Panda published interfaces look like. If it gets confused about Windows API’s, it doesn’t really do any harm. So, yeah, go ahead and leave this. It might be a good idea to set it to 1400 just so it doesn’t get set to nothing at all, which might reduce a few more errors down the road.

The other errors look like bad combination of compilation parameters. Some of the code that you’re linking together was compiled with some options, other code was compiled with conflicting options.

David

Ah, thanks again.
I think the ode.lib was a faulty build or so – I recompiled ode from scratch, but now it results in just one linker error.

link /nologo /NOD:MFC80.LIB /NOD:LIBCI.LIB /NOD:MSVCRTD.LIB /DEBUG  /nod:libc /nod:libcmtd /nod:atlthunk /DLL /MAP /MAPINFO:EXPORTS /FIXED:NO /OPT:REF /STACK:41
94304 /INCREMENTAL:NO  /OUT:built/bin/libpandaode.dll /IMPLIB:built/lib/libpandaode.lib /LIBPATH:"thirdparty/win-python/libs" built/tmp/pandaode_pandaode.obj built/tmp/libpandaode_module.obj built/tmp/pode_composite1.obj built/tmp/pode_composite2.obj built/tmp/pode_composite3.obj built/tmp/libpandaode_igate.obj built/lib/libpanda.lib built/lib/libpandaexpress.lib built/lib/libp3dtool.lib built/lib/libp3dtoolconfig.lib advapi32.lib thirdparty/win-libs-vc8/ode/lib/ode.lib
   Creating library built/lib/libpandaode.lib and object built/lib/libpandaode.exp

ode.lib(error.obj) : error LNK2019: unresolved external symbol __imp__MessageBox
A@16 referenced in function _dError
built/bin/libpandaode.dll : fatal error LNK1120: 1 unresolved externals

I’m using exactly the same makepanda code I used to compile this stuff on linux.

PS. what the heck is ‘advapi’? Lots of panda libs link to it but I have no clue what it is and if I would link to it. I tried also linking to it and it made no difference.

I dunno what advapi is. The missing reference to MessageBox is a little strange; that’s a Windows system call, right? One, it’s weird that we’re calling it, and two, it’s weird that it’s not present. Try googling to see if you can figure out which library that should be coming from.

David

I already did. I just can’t find it. Is it in the platformSDK that it could get linked wrong or so?

From http://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx (top Google hit on “MessageBox”):

Thus, you need to have User32.lib on the link line in order to resolve MessageBox. Maybe this is something that the ODE library is calling directly?

David

Yes, that lib indeed belongs to the PlatformSDK. Hmm, I thought makepanda linked there automatically. Thanks very much for your time, this fixed it perfectly.

I’m very sorry to bother you guys again, but I’m really lost now. genpycode fails to find my initlibpandaode. This is the makepanda code:

#
# DIRECTORY: panda/src/ode/
#
if (PkgSkip("ODE")==0):
    OPTS=['DIR:panda/src/ode', 'BUILDING:PANDAODE', 'ODE']
    TargetAdd('pode_composite1.obj', opts=OPTS, input='pode_composite1.cxx')
    TargetAdd('pode_composite2.obj', opts=OPTS, input='pode_composite2.cxx')
    TargetAdd('pode_composite3.obj', opts=OPTS, input='pode_composite3.cxx')
    IGATEFILES=GetDirectoryContents('panda/src/ode', ["*.h", "*_composite.cxx"])
    IGATEFILES.remove("odeConvexGeom.h")
    IGATEFILES.remove("odeHeightFieldGeom.h")
    IGATEFILES.remove("odeHelperStructs.h")
    TargetAdd('libpandaode.in', opts=OPTS, input=IGATEFILES)
    TargetAdd('libpandaode.in', opts=['IMOD:pandaode', 'ILIB:libpandaode', 'SRCDIR:panda/src/ode'])
    TargetAdd('libpandaode_igate.obj', input='libpandaode.in', opts=["DEPENDENCYONLY"])

#
# DIRECTORY: panda/metalibs/pandaode/
#
if (PkgSkip("ODE")==0):
    OPTS=['DIR:panda/metalibs/pandaode', 'BUILDING:PANDAODE', 'ODE']
    TargetAdd('pandaode_pandaode.obj', opts=OPTS, input='pandaode.cxx')
    
    TargetAdd('libpandaode_module.obj', input='libpandaode.in')
    TargetAdd('libpandaode_module.obj', opts=OPTS)
    TargetAdd('libpandaode_module.obj', opts=['IMOD:pandaode', 'ILIB:pandaode'])
    
    TargetAdd('libpandaode.dll', input='pandaode_pandaode.obj')
    TargetAdd('libpandaode.dll', input='libpandaode_module.obj')
    TargetAdd('libpandaode.dll', input='pode_composite1.obj')
    TargetAdd('libpandaode.dll', input='pode_composite2.obj')
    TargetAdd('libpandaode.dll', input='pode_composite3.obj')
    TargetAdd('libpandaode.dll', input='libpandaode_igate.obj')
    TargetAdd('libpandaode.dll', input=COMMON_PANDA_LIBS)
    TargetAdd('libpandaode.dll', opts=['WINUSER', 'ODE'])

I don’t see anything wrong with it. It just looks like everything else.

Did initlibpandaode get generated? Check the .so file (nm libpandaode.so | grep initpandaode).

Did interrogate_module run properly? Did its output get compiled into the library?

David

Yup, everything gets called and linked.
But I think I found the little stinker. I couldnt find an ‘nm’-like tool on windows, so I opened the dll with a hex editor. It didnt contain anything like “initlibpandaode”, but it did contain a “initpandaode”. So somehow it looks for just the wrong function.
I can workaround it by adding a quick hack in jGenPyCode.py, but thats not the way it’s meant to be, so I’m going to look how this goes wrong then. The .in file ain’t wrong, interrogate_module just does it wrong somehow.

EDIT: this is wrong:

built/bin/interrogate_module  -oc built/tmp/libpandaode_module.cxx -module pandaode -library pandaode -python-native  built/pandac/input/libpandaode.in
Referencing Library libpandaode

the -library should be libpandaode. What a stupid mistake of me, I needed to set ILIB:libpandaode instead of pandaode. I guess it would work now.

EDIT2: damn it. Just now I thought this was over.

[size=150]YAY![/size]
Dunno what that was, but I finally got it working.
It’s in now, should be everything. Let me know if there’s anything missing or so. I guess Josh will now decide in what release it’s gonna be.
Thanks very much for your help, drwr and Josh! I really learnt alot from you guys.