Hello World/RoamingRalph problem in SnowLeopard/c++

I downloaded the 1.7.0 SDK installer and the demos.
So far, the python demos seem to work just fine. I worked through the tutorial in the manual for the Hello World app.

In the last step, i ran into a problem where the panda would animate, but not path. The python version of this step worked just fine. I figured that working on a different sample would lend some insight, so the guys in the IRC channel suggested Roaming Ralph, C++. It segfaulted all over.

I cut pieces out to narrow down the problem to just one at a time.
Here’s a link to the code, and the points where it failed. ( pastebin.com/gzvrwzZL ) I have no idea why it’s dying there, of all places. I talked to the guys on the chat channel. (Those guys ROCK, by the way) They couldn’t figure it out either. We tried an assert and putting the string on the stack.

Essentially, what I’m wondering is: Is there a bug in the osx version? Am I doing something wrong? Thanks in advance! :slight_smile:

OS-X 10.6.2, i686-apple-darwin10-gcc-4.2.1, Python 2.6.1, Xcode 3.2 (using the template for 1.62 apps posted by another forum-goer)

-------EDIT------

Instructions, so others may get 1.7.0 working on Snow Leopard.

Download the freshest code
( cvs -d :pserver:anonymous@panda3d.cvs.sourceforge.net:/cvsroot/panda3d co panda3d )
Download the base 1.7.0 SDK and copy the thirdparty directory into the equivalent folder in the cvs one.
Update your port of GTK2 to support 32-bit. Note: Not all dependencies update on their own; you’ll have to manually port some of them. Run port with +universal set to get the right ones.
If you’ve updated to GTK2 you’re probably using libjpeg v7, or higher. You’ll need to update the headers in the thirdparty folder. In thirdparty/darwin*/jpeg you’ll want to replace the files in there with their equivalents from /opt/local/include and /opt/local/lib/
Tell python to run in 32-bit
( export VERSIONER_PYTHON_PREFER_32_BIT=yes )
in the panda3d folder of the cvs image, start the compile
( python makepanda/makepanda.py --everything --installer --verbose)
On a MacBook 5.2 this takes about 34 minutes. This will create a .dmg that contains the installer. Install it.

The Xcode template at: discourse.panda3d.org/viewtopic … 3925#43925
Will NOT work properly as-is. With a few changes, though it’ll do.
Change the include and lib folders in the project settings.
Right click each dylib, Get Info, and point them at the new dylibs in /Developer/Panda3D/lib
The 3 .a files (which I don’t think you need) are not copied by the script. If you want them, they’re in built/lib. Put them in /Developer/Panda3D/lib and update the links like you did for the dylibs.
IMPORTANT (and, incidentally, the source of all this work)
In project settings, GCC Preprocessing:
Get rid of: GLIBCXX_DEBUG=1

I hope this helps others.
-Sherlock

Hmm, a crash in C++ string operations usually means a C++ ABI issue, for instance because the version of the Panda library you are linking with was compiled with a different compiler (using a different C++ ABI) than the one you are using to build your application.

Maybe the best answer is to download the Panda source and compile it yourself using your native compiler, then link with that library.

David

I worked with the awesome people in the chat room for a few hours last night on compiling. We got over a few hurdles and it makes it a fair ways through now. Ive got a problem with the build, still though. At the time, i thought that getting it to compile on my system was something that would be nice, but not necessary. They were really helpful, and I didn’t want to monopolize their time.

We got it as far as 28% previously, but something in the last fix caused a new problem. Here’s where it stopped last time:

[ 7%] Building Interrogate database built/pandac/input/libexpress.in
built/bin/interrogate -srcdir panda/src/express -Ipanda/src/express -Dvolatile -Dmutable -DFORCE_INLINING -oc built/tmp/libexpress_igate.cxx -od built/pandac/input/libexpress.in -fnames -string -refcount -assert -python-native -Sbuilt/include/parser-inc -Ipanda/src/express -S/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -S/opt/local/include -Sbuilt/tmp -Sbuilt/include -DMAKEPANDA= -DBUILDING_PANDAEXPRESS -module pandaexpress -library libexpress buffer.h checksumHashGenerator.h circBuffer.h compress_string.h config_express.h copy_stream.h datagram.h datagramGenerator.h datagramIterator.h datagramSink.h dcast.h encrypt_string.h error_utils.h export_dtool.h express_composite.cxx hashGeneratorBase.h hashVal.h indirectLess.h memoryInfo.h memoryUsage.h memoryUsagePointerCounts.h memoryUsagePointers.h multifile.h namable.h nodePointerTo.h nodePointerToBase.h nodeReferenceCount.h openSSLWrapper.h ordered_vector.h pStatCollectorForwardBase.h password_hash.h patchfile.h pointerTo.h pointerToArray.h pointerToArrayBase.h pointerToBase.h pointerToVoid.h profileTimer.h pta_float.h pta_int.h pta_uchar.h ramfile.h referenceCount.h stringDecoder.h subStream.h subStreamBuf.h textEncoder.h threadSafePointerTo.h threadSafePointerToBase.h trueClock.h typedReferenceCount.h typedef.h unicodeLatinMap.h vector_float.h vector_uchar.h virtualFile.h virtualFileComposite.h virtualFileList.h virtualFileMount.h virtualFileMountMultifile.h virtualFileMountSystem.h virtualFileSimple.h virtualFileSystem.h weakPointerCallback.h weakPointerTo.h weakPointerToBase.h weakPointerToVoid.h weakReferenceList.h windowsRegistry.h zStream.h zStreamBuf.h
*** Error in /Users/mark/MakePanda/panda3d/built/include/parser-inc/memory near line 42, column 27:
syntax error, unexpected TYPENAME_IDENTIFIER, expecting ‘{’ or ‘;’ or ‘:’ or ‘=’
Error parsing file: ‘buffer.h’
Interrogate failed, retrieving debug output…

Hmm, try removing the line in question, line 42 of dtool/src/inc/parser-inc/memory. I don’t think it’s needed.

David

This problem showed up after they changed a few pieces on the difference between longs on 64-bit osx and other archs.

The subsequent line caused a similar error. I commented it out as well. The next error after that is in a file that’s not in parser-inc, so I wasn’t sure if i should continue the removes. Thanks for the help :slight_smile:

[ 7%] Building Interrogate database built/pandac/input/libexpress.in
built/bin/interrogate -srcdir panda/src/express -Ipanda/src/express -Dvolatile -Dmutable -DFORCE_INLINING -oc built/tmp/libexpress_igate.cxx -od built/pandac/input/libexpress.in -fnames -string -refcount -assert -python-native -Sbuilt/include/parser-inc -Ipanda/src/express -S/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -S/opt/local/include -Sbuilt/tmp -Sbuilt/include -DMAKEPANDA= -DBUILDING_PANDAEXPRESS -module pandaexpress -library libexpress buffer.h checksumHashGenerator.h circBuffer.h compress_string.h config_express.h copy_stream.h datagram.h datagramGenerator.h datagramIterator.h datagramSink.h dcast.h encrypt_string.h error_utils.h export_dtool.h express_composite.cxx hashGeneratorBase.h hashVal.h indirectLess.h memoryInfo.h memoryUsage.h memoryUsagePointerCounts.h memoryUsagePointers.h multifile.h namable.h nodePointerTo.h nodePointerToBase.h nodeReferenceCount.h openSSLWrapper.h ordered_vector.h pStatCollectorForwardBase.h password_hash.h patchfile.h pointerTo.h pointerToArray.h pointerToArrayBase.h pointerToBase.h pointerToVoid.h profileTimer.h pta_float.h pta_int.h pta_uchar.h ramfile.h referenceCount.h stringDecoder.h subStream.h subStreamBuf.h textEncoder.h threadSafePointerTo.h threadSafePointerToBase.h trueClock.h typedReferenceCount.h typedef.h unicodeLatinMap.h vector_float.h vector_uchar.h virtualFile.h virtualFileComposite.h virtualFileList.h virtualFileMount.h virtualFileMountMultifile.h virtualFileMountSystem.h virtualFileSimple.h virtualFileSystem.h weakPointerCallback.h weakPointerTo.h weakPointerToBase.h weakPointerToVoid.h weakReferenceList.h windowsRegistry.h zStream.h zStreamBuf.h
*** Error in /Users/mark/MakePanda/panda3d/built/include/atomicAdjustDummyImpl.h near line 33, column 17:
syntax error, unexpected KW_STATIC, expecting ‘{’ or ‘;’ or ‘:’ or ‘=’
Error parsing file: ‘buffer.h’
Interrogate failed, retrieving debug output…
Reading buffer.h

Hmm, for some reason interrogate isn’t understanding the INLINE keyword.

Perhaps the problem is the -DFORCE_INLINING argument on the interrogate command line. I don’t know what that is doing there; it doesn’t belong there for interrogate. I don’t really think it belongs there ever, but whatever. I see that lines 768 and 769 of makepanda.py appear to be adding this to the interrogate command line, which is I think a mistake. Try removing this.

But I don’t understand how this could be causing the problem, honestly, since FORCE_INLINING shouldn’t be doing anything unless WIN32_VC is defined, which certainly shouldn’t be true for an osx build.

Try inserting an #error in dtoolbase_cc.h, right here:

#if defined(WIN32_VC) && defined(FORCE_INLINING)
// If FORCE_INLINING is defined, we use the keyword __forceinline,
// which tells MS VC++ to override its internal benefit heuristic
// and inline the fn if it is technically possible to do so.
#define INLINE __forceinline
#else
#define INLINE inline
#ifdef CPPPARSER
#error 1
#endif
#endif

I show the #error 1 line protected by #ifdef CPPPARSER, so it won’t interrupt the gcc step (CPPPARSER is only defined when interrogate is running).

David

Sadly, no change. It’s still stuck at the same spot. Is there any information i could gather that’d help more?

Oh! Wait a second!

The problem is caused by a faulty ‘if’ statement that I checked into makepanda recently. In this particular case, it omits important flags like -DCPPPARSER and -D__inline. :stuck_out_tongue:

I’ve just checked in a fix to makepanda. Try and see if it works now.

David, should I remove the FORCE_INLINING flag? Makepanda sets it in optimize levels 3 and 4.

I think so. I guess it hasn’t caused any actual problems, other than misleading me, but it shouldn’t be passed to interrogate. It can remain for the compiler itself, though, although I don’t think it does any good.

David

Alrighty, update. Thanks to a pile of help from rdb, I managed to get a copy of Panda to build on snow leopard. The latest cvs version will compile cleanly if:

-before building: export VERSIONER_PYTHON_PREFER_32_BIT=yes
-gtk2 is installed from ports with +universal set
" sudo ports install gtk2 +universal " You may need to upgrade some dependencies too. They don’t all auto-upgrade.

On a side note, i was missing a .h for osmesa, so it was compiled without it.

The tiny program that I have pastebinned in the first post is still crashing on the same line. The helloworld app now exits on status 1, with the below on the console. (note the jpeg line? ) Here’s the crash report: pastebin.com/iZbBBvjm

Known pipe types:
osxGraphicsPipe
(all display modules loaded.)
Sun Mar 28 10:33:33 Sherlock-2.local Panda[52358] : kCGErrorIllegalArgument: CGSCopyRegion : Null pointer
Sun Mar 28 10:33:33 Sherlock-2.local Panda[52358] : kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Loading models/environment
Wrong JPEG library version: library is 70, caller expects 62
Sun Mar 28 10:33:33 Sherlock-2.local Panda[52358] : kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 4372
Sun Mar 28 10:33:33 Sherlock-2.local Panda[52358] : kCGErrorIllegalArgument: CGSRemoveSurface: Invalid window 0x1114

Little update: It seems that the jpeg part might be the problem. Commenting out basically everything but the loading of the models still exits. Removing the model loads causes the panda window to stay up.

I’d think it is an ABI mismatch between the version of jpeg that is linked to Panda, and the one that is being loaded.
Could it be that there are multiple versions of libjpeg on your system? If so, could you try removing the one you really don’t need, removing the dylibs in built/lib (and uninstalling Panda3D from /Developer/Panda3D) and rebuilding?

Okay, looks like i need to do more fiddling with the libjpeg. I got all my versions set to 6.2, and HelloWorld runs. However, most of the textures don’t load–theyre all white. The panda still doesn’t path.

The textnode dummy program still segfaults at the same spot. >.<

Alright, update. I have panda3d building completely on Snow Leopard. However, I’m back to the problem of the initial post.

Running the set_text method on TextNode seems to segfault as if it were being called on null, or something like it. I’ve tried passing a string in that’s on the stack, with the same results.

Secondly, there seems to be something odd with the Hello World app that prevents the panda from pathing. I know i’m getting hung up on little details here, but I’m trying to learn Panda, and it’s difficult when I can’t get the example code working. >.<

If there’s some other demos that are known to work on other systems (in C++), i’d very much appreciate some links so I can try them out.

Again, thank-you to everyone. Your help is amazing. I’ll be updating the top post with instructions to get 1.7.0 compiling on Snow Leopard.

Hmm, something’s still very wrong. Some kind of low-level mismatch between your application, and the way Panda was built.

Is it possible that you’re compiling your application with an NDEBUG flag, and Panda without it, or vice-versa?

Try to duplicate exactly the options used to compile Panda in your own application.

David

You, sir, are a genius. Panda is pathing. Text is texting.

I manually command-line compiled the project using the same arguments as in panda, and it worked beautifully.

Thank you, muchly.

g++ -ftemplate-depth-30 -fPIC -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I/Developer/Panda3D/lib -I/Developer/Panda3D/include -DMAKEPANDA= -Wno-deprecated-declarations -arch i386 -O2 -DBUILDING_PANDA main.cpp /Developer/Panda3D/lib/libp3dtool.dylib /Developer/Panda3D/lib/libp3framework.dylib /Developer/Panda3D/lib/libp3dtoolconfig.dylib /Developer/Panda3D/lib/libp3pystub.dylib /Developer/Panda3D/lib/libpandafx.dylib /Developer/Panda3D/lib/libpandaexpress.dylib /Developer/Panda3D/lib/libpanda.dylib /Developer/Panda3D/lib/libp3direct.dylib

If you can figure out which particular parameter change causes this conflict, we might be able to write some code to protect against the problem, or at least warn about it, in the future.

Thanks!
David

Okay, found it. The template i was using from another forum poster had _GLIBCXX_DEBUG=1 set in Xcode. The command-line parameter in gcc for that is -D_GLIBCXX_DEBUG=1

I removed this, and it all worked great!

OK, I don’t know what that does, but I bet it’s pretty disruptive to application-level code. It probably doesn’t make sense for us to bother testing for it explicitly, since it sounds like it got into your template more-or-less accidentally, and it’s probably unlikely that someone else would repeat the exact same mistake.

Thanks!
David

I’ve modified the Xcode template to work with current 1.7.0 settings. Is there a way i can zip it and post it? Maybe DCC it to someone in the chat room, so that other ppl can have an easier time getting started?