Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ code in iPhone app

Tags:

c++

xcode

iphone

I'm trying to use a C++ library (CLucene) from my Cocoa Touch iPhone application using Xcode 3.1.3. Everything works fine when I run in the iPhone simulator, but things get strange when I run on device. It seems like pointers aren't being passed correctly from the Objective-C++ code (my app) to the C++ library (CLucene).

While debugging the app on device, I can watch a const char* variable passed as a parameter to a C++ function change from 0x12546c0 in Objective-C++ to 0x4e in C++. Since 0x4e doesn't point to a valid const char*, the C++ code fails. This doesn't happen when debugging in the simulator.

I'm compiling the C++ library directly into the app, not linking to a static or dynamic lib.

Any help would be much appreciated.

like image 701
Jeremy Bower Avatar asked Jun 29 '09 18:06

Jeremy Bower


1 Answers

Disabling "Compile for Thumb" in the project's build settings fixes the problem.

like image 61
Jeremy Bower Avatar answered Oct 14 '22 07:10

Jeremy Bower