Segment Query issue with Chipmunk Pro 6

Official forum for the Chipmunk2D Physics Library.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Segment Query issue with Chipmunk Pro 6

Post by slembcke »

I dunno, there's that nagging voice inside of me saying that if you think it's a compiler bug, there's almost no way it's a compiler bug. I've gotten GCC to crash on a number of occasions when using some weird syntax, but never to output bad code. On the other hand, I just don't see how the assembly it outputs for that function is correct is correct. It very clearly is loading the the function argument from the wrong stack index, and I have no idea how to explain why it's doing it any other way. As a C programmer, you cannot change the stack pointer register, and I'm not accidentally trashing the memory location where the function pointer is stored through a bad pointer or anything lie that. The bug also only occurs when function inlining is enabled. So...

Anyway, switching to Clang is very easy. Clang is the open source compile Apple has been developing for a few years now based on LLVM. It's recommended to be used with Xcode 4 going forward anyway. Open the Objective-Chipmunk project, then double click the project icon in Xcode's hierarchy. Switch to the build settings tab and find the "C/C++ Compiler Version" setting. Change it to "llvm compiler". It's called Clang when you invoke it from command line. No idea why they didn't just call it that. It provides a nearly identical feature set to GCC, so it's not like it's a big switch or anything.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
RodMath
Posts: 17
Joined: Sun May 09, 2010 2:48 pm
Contact:

Re: Segment Query issue with Chipmunk Pro 6

Post by RodMath »

Hmm, I still can't get it to work, probably simply due to my lack of compiler/linking knowledge.

So, I've tried changing the compiler for my project to LLVM Compiler 2.0 (I'm using XCode 4) and rebuilding, but it still fails. Similarly SimpleObjectiveChipmunk also fails when I change to LLVM. Presumably this is because I need to recompile the Chipmunk part, but I'm not sure how.

In my project I've just copied the libObjectiveChipmunk-iphone folder into my project, so do I need to somehow compile a new one of these to copy in?

Meanwhile I see the SimpleObjectiveChipmunk uses some other method of accessing Objective Chipmunk (other linker flags?), is that an easier/better way of bringing it in? If so could you possibly let me know how it is done?

Thanks again for all the help
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Segment Query issue with Chipmunk Pro 6

Post by slembcke »

Yes, you need to compile a new one. Change the settings in the Objective-Chipmunk Xcode project and rebuild the library using the iphonestatic.command script (you can just double click it in the finder). That will rebuild the Objective-Chipmunk-iPhone folder with the new Xcode settings.

In the SimpleObjectiveChipmunk project I manually set up search and linker paths so that the project falls back onto the trial version of Objective-Chipmunk if the bought version isn't found at the right location. You don't really want to do that. Either copy the Objective-Chipmunk-iPhone folder into your project (simpler) or use a Xcode cross project reference (I generally avoid this).
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
RodMath
Posts: 17
Joined: Sun May 09, 2010 2:48 pm
Contact:

Re: Segment Query issue with Chipmunk Pro 6

Post by RodMath »

Hooray, after a bit of jiggery pokery learning about universal builds etc it now all works!

The iphoneStatic script didn't work for me, I think due to the default Xcode 4 settings? It uses derived build locations so the lipo commands can't find the libObjectiveChipmunk.a files. It probably is possible to get this to work in the script using some environment variables, but I found it beyond me.

In case anyone else is in the same position I ended up:
1) In the objective chipmunk iphone project change the compiler setting to LLVM and build for device
2) Using the approach here: http://red-glasses.com/index.php/tutori ... simulator/ make a universal build.
3) Copy this new universal file (I used Get Info on libObjectiveChipmunk.a to find the right derived folder, then went to the ...-universal folder to get the actual file) into the Objective-Chipmunk-iPhone folder.
4) Delete all old Objective Chipmunk bits from my xcode project (and checked in Finder because sometimes it doesn't seem to delete)
5) Copy in the new Objective-Chipmunk-iPhone folder
6) Give Xcode a shake (clean, build, run, if it fails, close xcode, open xcode, clean again, build again, compile again... ), and presto segment queries now work on Simulator and Device :-)

As an aside, I also have to change to setting of CP_ALLOW_PRIVATE_ACCESS to 1 to get it to build successfully - is that expected?

Thanks for your help though.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Segment Query issue with Chipmunk Pro 6

Post by slembcke »

Hmm. That's weird. The xcodebuild command line tool is supposed to generate a "build" directory in the same directory as the project like Xcode/ProjectBuilder did up until Xcode 4. Is that not the case? You also shouldn't have needed to change CP_ALLOW_PRIVATE_ACCESS. Hmm. -_-

Good to hear you got it working Ok. I'll look into the build issues for 6.0.1.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests