I tried posting this question to the Android Internals mailing list, but that list seems to be inactive...
Goal: I am trying to gain access to raw camera data on the G1 from native code (JNI C++) so that I can do real time image processing on camera frames at 15 fps. This will not work in the Java API because it takes too long for the camera preview callback to load the data. Setup: I am using the CodeSourcery C++ cross-compilation toolchain for ARM development on Windows. I include the relevant header files from the Android source code and create a shared library object using the following commands (my project name is flow): arm-none-linux-gnueabi-g++ -I"C:\Program Files\Java\jdk1.6.0_11\include" -I"C:\Program Files\Java\jdk1.6.0_11\include\linux" -I"C:\Program Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\core\include" -I"C:\Program Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\base\include" -I"C:\Program Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\msm7k" -I"C:\Program Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\base\camera\libcameraservice" -I"C:\Program Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\common\include" -fpic -c flow.c arm-none-linux-gnueabi-ld --dynamic-linker /system/bin/linker -nostdlib -I /system/bin/linker -rpath-link /system/lib -L"C:\Program Files\CodeSourcery\Sourcery G++ Lite\arm-none-linux-gnueabi\lib\ldscripts" -L. -shared -o libflow.so flow.o -z now @minlibs.inc where minlibs.inc contains: -lcameraservice -lcamera -lui -lpixelflinger -lhardware -lgps -lcorecg -lOmxH264Dec -lutils -lqcamera -lwpa_client -lnetutils -lcutils -lrpc -llog -lz -lstdc++ -lm -lc -ldl In order to link, I pulled copies of all the libraries in the /system/lib folder on the device to my computer. Then I take this shared library object and copy it to the resource directory of my Java Android project in Eclipse. This Android activity uses System.load() to load my shared object and then I call the functions in the shared object from Java by standard JNI. What works: I am able to run activities on the phone that call JNI functions which contain calls to Android functions. For example, I was able to write a message to the log and call android::CameraService::instantiate() and see the log messages in the ddms debugger. Problem: The camera libraries that I would like to interface with are using a template class sp. A function I want to use returns type: android::sp<android::CameraHardwareInterface>. As soon as I declare a variable of this type, the constructor and destructor are required. Despite lengthy efforts, I have not been able to get a program to run that contains this type declaration. The code builds and links fine on my computer, without warnings, but the Activity crashes immediately upon execution and the ddms debugger just says that my shared object is "not found" whenever this type declaration is present. I do not know how to get any more detailed debug messages from the dynamic linker. What I've tried: I made a batch file that scans through all the libraries using arm-none-linux-gnueabi-nm -C -D to find the symbols needed to declare this type. I believe that my minlibs.inc file contains all necessary libraries, however I am not sure. The code for the constructor and destructor of sp is directly in the header files that I have included and the only functions they reference are incStrong and decStrong, which are found in libutils.so, which I have linked to. I also sorted the relevant libraries based on dependencies obtained using arm-none-linux-gnueabi-objdump -p as can be seen in the minlibs.inc file above. I also tried using an alternate constructor by passing in a null pointer: android::QualcommCameraHardware *qcam = NULL; android::sp<android::CameraHardwareInterface> cam(qcam); //android::sp<android::CameraHardwareInterface> cam; My C++ function really only contains these lines, a call to __android_log_write, and return. Question: Any ideas on how to get this to run without crashing? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---