osX+android: linker error

Hi,
I was trying to get oF 007 working in osX/eclipse/android configuration. Unfortunatly I got errors at linking stage about ofSoundShutdown(). As i saw, file implementing that function (ofSoundPlayer.cpp) doesn’t get compiled on andoroid targets. Funny thing is that it doesnt lead to such a problems when building with ubuntu/eclipse/android configuration.

When building with AndroidDebug there is that linking error:

  
/Developer/Piotr/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: warning: libcutils.so, needed by /Developer/Piotr/android-ndk-r6/platforms/android-8/arch-arm//usr/lib/libGLESv1_CM.so, not found (try using -rpath or -rpath-link)  
/Developer/Piotr/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: warning: libEGL.so, needed by /Developer/Piotr/android-ndk-r6/platforms/android-8/arch-arm//usr/lib/libGLESv1_CM.so, not found (try using -rpath or -rpath-link)  
../../../libs/openFrameworksCompiled/lib/android/libopenFrameworksDebug.a(ofAppRunner.o): In function `ofExitCallback()':  
/Users/mac/Documents/of_preRelease_v007_android/libs/openFrameworksCompiled/project/android/../../../openFrameworks/app/ofAppRunner.cpp:131: undefined reference to `ofSoundShutdown()'  
collect2: ld returned 1 exit status  
make[1]: *** [obj/androidPolygonExample] Error 1  
make: *** [AndroidDebug] Error 2  

When building with AndroidRelease it compiles but crashes right after start of an application with LogCat like this:

  
08-24 01:08:46.960: INFO/OF(8444): failed neon detection, loading not-neon library  
08-24 01:08:46.960: INFO/OF(8444): java.lang.UnsatisfiedLinkError: Couldn't load neondetection: findLibrary returned null  
08-24 01:08:46.960: INFO/OF(8444):     at java.lang.Runtime.loadLibrary(Runtime.java:429)  
08-24 01:08:46.960: INFO/OF(8444):     at java.lang.System.loadLibrary(System.java:554)  
08-24 01:08:46.960: INFO/OF(8444):     at cc.openframeworks.OFAndroid.<clinit>(OFAndroid.java:512)  
08-24 01:08:46.960: INFO/OF(8444):     at cc.openframeworks.androidPolygonExample.OFActivity.onCreate(OFActivity.java:19)  
08-24 01:08:46.960: INFO/OF(8444):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)  
08-24 01:08:46.960: INFO/OF(8444):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)  
08-24 01:08:46.960: INFO/OF(8444):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)  
08-24 01:08:46.960: INFO/OF(8444):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)  
08-24 01:08:46.960: INFO/OF(8444):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)  
08-24 01:08:46.960: INFO/OF(8444):     at android.os.Handler.dispatchMessage(Handler.java:99)  
08-24 01:08:46.960: INFO/OF(8444):     at android.os.Looper.loop(Looper.java:130)  
08-24 01:08:46.960: INFO/OF(8444):     at android.app.ActivityThread.main(ActivityThread.java:3835)  
08-24 01:08:46.960: INFO/OF(8444):     at java.lang.reflect.Method.invokeNative(Native Method)  
08-24 01:08:46.960: INFO/OF(8444):     at java.lang.reflect.Method.invoke(Method.java:507)  
08-24 01:08:46.960: INFO/OF(8444):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)  
08-24 01:08:46.960: INFO/OF(8444):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)  
08-24 01:08:46.960: INFO/OF(8444):     at dalvik.system.NativeStart.main(Native Method)  
08-24 01:08:46.960: DEBUG/dalvikvm(8444): Trying to load lib /mnt/asec/cc.openframeworks.androidPolygonExample-1/lib/libOFAndroidApp.so 0x40516488  
08-24 01:08:47.030: DEBUG/VoiceDialerReceiver(3763): onReceive Intent { act=android.intent.action.PACKAGE_ADDED dat=package:cc.openframeworks.androidPolygonExample flg=0x10000000 cmp=com.android.voicedialer/.VoiceDialerReceiver (has extras) }  
08-24 01:08:47.030: VERBOSE/RecognizerEngine(3763): deleteCachedGrammarFiles /data/data/com.android.voicedialer/files/openentries.txt  
08-24 01:08:47.080: DEBUG/InstallReceiver(3778): cc.openframeworks.androidPolygonExample  
08-24 01:08:47.360: WARN/dalvikvm(8444): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcc/openframeworks/OFAndroid;  
08-24 01:08:47.360: DEBUG/AndroidRuntime(8444): Shutting down VM  
08-24 01:08:47.360: WARN/dalvikvm(8444): threadid=1: thread exiting with uncaught exception (group=0x40018560)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444): FATAL EXCEPTION: main  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444): java.lang.ExceptionInInitializerError  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at cc.openframeworks.androidPolygonExample.OFActivity.onCreate(OFActivity.java:19)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.os.Handler.dispatchMessage(Handler.java:99)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.os.Looper.loop(Looper.java:130)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at android.app.ActivityThread.main(ActivityThread.java:3835)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at java.lang.reflect.Method.invokeNative(Native Method)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at java.lang.reflect.Method.invoke(Method.java:507)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at dalvik.system.NativeStart.main(Native Method)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1311]:  1226 cannot locate '_Z15ofSoundShutdownv'...  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at java.lang.Runtime.loadLibrary(Runtime.java:434)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at java.lang.System.loadLibrary(System.java:554)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     at cc.openframeworks.OFAndroid.<clinit>(OFAndroid.java:522)  
08-24 01:08:47.360: ERROR/AndroidRuntime(8444):     ... 14 more  
08-24 01:08:47.370: WARN/ActivityManager(1333):   Force finishing activity cc.openframeworks.androidPolygonExample/.OFActivity  
  

Actually, adding ofSoundPlayer1.cpp shown below solved the issue, but I’m curious if there is any “cleaner” method to fix it.

  
#include "ofSoundPlayer.h"  
#include "ofUtils.h"  
  
//--------------------  
void ofSoundShutdown(){  
}  

Regards

Yes this is already fixed in git. The problem is that since there’s no reference to that function directly from your code the linker doesn’t include that symbols but actually that function is called from inside OF so finally you get an undefined symbol error.

Anyway if you want to update to latest in git master it’s fixed there or as you said just defining it in your own code solves the problem