Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking error on master for Android devices running < 5.0 (Lollipop) #4171

Closed
mhashmi opened this issue Jul 29, 2015 · 26 comments
Closed

Linking error on master for Android devices running < 5.0 (Lollipop) #4171

mhashmi opened this issue Jul 29, 2015 · 26 comments

Comments

@mhashmi
Copy link
Contributor

mhashmi commented Jul 29, 2015

For devices running anything under Lollipop (5.0), we get linking errors when launching any of the android example apps.

We tried NDK r10e, r10b, r9b and r9d to confirm against the androidEmptyExample.

Please find below the linker error:

Compiling androidEmptyExample for Debug
HOST_OS=Darwin
HOST_ARCH=x86_64
make[1]: Entering directory `/Users/mustafa/Development/ofHead/examples/android/androidEmptyExample'
Linking libs/armeabi-v7a/libOFAndroidApp.so for android/armeabi-v7a
/Users/mustafa/Development/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++ -o libs/armeabi-v7a/libOFAndroidApp.so  obj/android/armv7/Debug/src/main.o obj/android/armv7/Debug/src/ofApp.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofAppAndroidWindow.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidAccelerometer.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidGPS.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidLogChannel.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidSoundPlayer.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidSoundStream.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidUtils.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidVibrator.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidVideoGrabber.o ../../../addons/obj/android/armv7/Debug/ofxAndroid/src/ofxAndroidVideoPlayer.o ../../../addons/obj/android/armv7/Debug/ofxAccelerometer/src/ofxAccelerometer.o ../../../libs/openFrameworksCompiled/lib/android/armv7/libopenFrameworksDebug.a   --sysroot=/Users/mustafa/Development/Android/ndk/platforms/android-19/arch-arm/ -nostdlib -L"/Users/mustafa/Development/Android/ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a" -Wl,--fix-cortex-a8 -shared -Wl,--no-undefined -Wl,--as-needed -Wl,--gc-sections -Wl,--exclude-libs,ALL ../../../libs/FreeImage/lib/android/armeabi-v7a/libfreeimage.a ../../../libs/boost/lib/android/armeabi-v7a/libboost_filesystem.a ../../../libs/boost/lib/android/armeabi-v7a/libboost_system.a ../../../libs/freetype/lib/android/armeabi-v7a/libfreetype.a ../../../libs/glu/lib/android/armeabi-v7a/libGLU.a ../../../libs/tess2/lib/android/armeabi-v7a/libtess2.a  ../../../libs/poco/lib/android/armeabi-v7a/libPocoNetSSL.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoNet.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoCrypto.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoJSON.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoMongoDB.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoDataSQLite.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoData.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoUtil.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoXML.a ../../../libs/poco/lib/android/armeabi-v7a/libPocoFoundation.a ../../../libs/openssl/lib/android/armeabi-v7a/libssl.a ../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a   -lOpenSLES -lsupc++ -lz -lGLESv1_CM -lGLESv2 -llog -ldl -lm -lc -lgnustl_static -lgcc
make[1]: Leaving directory `/Users/mustafa/Development/ofHead/examples/android/androidEmptyExample'
make: Leaving directory `/Users/mustafa/Development/ofHead/examples/android/androidEmptyExample'

../../../libs/poco/lib/android/armeabi-v7a/libPocoFoundation.a(Thread.o):Thread.cpp:function Poco::ThreadImpl::runnableEntry(void*): error: undefined reference to 'sigemptyset'
../../../libs/poco/lib/android/armeabi-v7a/libPocoFoundation.a(Thread.o):Thread.cpp:function Poco::ThreadImpl::runnableEntry(void*): error: undefined reference to 'sigaddset'
../../../libs/poco/lib/android/armeabi-v7a/libPocoFoundation.a(Thread.o):Thread.cpp:function Poco::ThreadImpl::runnableEntry(void*): error: undefined reference to 'sigaddset'
../../../libs/poco/lib/android/armeabi-v7a/libPocoFoundation.a(Thread.o):Thread.cpp:function Poco::ThreadImpl::runnableEntry(void*): error: undefined reference to 'sigaddset'
../../../libs/poco/lib/android/armeabi-v7a/libPocoFoundation.a(Thread.o):Thread.cpp:function _GLOBAL__sub_I_Thread.cpp: error: undefined reference to 'sigemptyset'
../../../libs/poco/lib/android/armeabi-v7a/libPocoFoundation.a(Thread.o):Thread.cpp:function _GLOBAL__sub_I_Thread.cpp: error: undefined reference to 'sigaddset'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigfillset'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
../../../libs/openssl/lib/android/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'
collect2: error: ld returned 1 exit status
make[1]: *** [libs/armeabi-v7a/libOFAndroidApp.so] Error 1
make: *** [Debug] Error 2

Please also see this forum thread for additional details.

Thank you.

@sterlingcrispin
Copy link
Contributor

having the same issues would be interested in a solution

@bilderbuchi
Copy link
Member

ping @openframeworks/android

@arturoc
Copy link
Member

arturoc commented Aug 4, 2015

copying from the forum:

we need to recompile the libraries using NDK_PLATFORM android-19 and hope that will work in both android 4 and 5.

if someone wants to give it a try, you can configure apothecary to use android-19 by editing scripts/apothecary/android_configure.sh and changing line 3 to:

export NDK_PLATFORM=android-19

then run apothecary from scripts/apothecary like:

./apothecary -t android update openssl

and then:

./apothecary -t android update poco

which are the libraries that seem to have problems, you would need to do the same for any library with undefined symbols.

if anyone gets it to work with android 4 and can send a pull request i can test it on android 5.

@tallavi is giving this a try. btw, @bilderbuchi can you add @tallavi to @openframeworks/android ?

@tallavi
Copy link

tallavi commented Aug 4, 2015

I updated the result of my attempt in the forum: http://forum.openframeworks.cc/t/android-master-branch/20106/9

Attached also here below.

I suspect permissions issues on ostype.sh (also found an old closed issue about it), but couldn't make it work. I have no leads on the other issues yet. Help?


Tals-Air:apothecary tallavi$ ./apothecary -t android update poco

----- poco -----

Downloading "poco"

SHA== https://github.com/pocoproject/poco
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 136 0 136 0 0 146 0 --:--:-- --:--:-- --:--:-- 146
0 0 0 7232k 0 0 1016k 0 --:--:-- 0:00:07 --:--:-- 1748k

Preparing "poco"

/Users/tallavi/Development/Trailze/ThirdParty/openFrameworks-latest-merged/scripts/apothecary/apothecary: line 68: ./ostype.sh: No such file or directory
/Users/tallavi/Development/Trailze/ThirdParty/openFrameworks-latest-merged/scripts/apothecary/apothecary: line 932: XS: unbound variable

^ Received error ^

^ Received error ^
Tals-Air:apothecary tallavi$ ./apothecary -t android update openssl

----- openssl -----

Downloading "openssl"

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 317 100 317 0 0 216 0 0:00:01 0:00:01 --:--:-- 216
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 322 100 322 0 0 623 0 --:--:-- --:--:-- --:--:-- 622
Invalid shasum for openssl-1.0.2c.
It looks like downloading failed for "openssl"

@tallavi
Copy link

tallavi commented Aug 4, 2015

BTW, the error described above is not the same that I am getting. I have a run time error on Android <5 devices. It actually doesn't make sense to have linking error on <5 devices :-)

@arturoc
Copy link
Member

arturoc commented Aug 4, 2015

don't you have ostype.sh in the apothecary folder with execution permissions?

@tallavi
Copy link

tallavi commented Aug 4, 2015

I do (as I pulled latest master):

-rwxrwxrwx 1 tallavi staff 767 Feb 3 18:40 ostype.sh

Check out this close issue: openframeworks/apothecary#21

I bet it's something like that, but I'm not sure what else to try other than chmod +x or 777. I tried sudo also. Didn't help.

@tallavi
Copy link

tallavi commented Aug 4, 2015

Any ideas regarding the other errors (sha of openssl, XS: unbound variable)?

@sterlingcrispin
Copy link
Contributor

I have X permissions on all the files in that directory and have the same Invalid shasum for openssl-1.0.2c.

further inspection shows

scripts/apothecary/formulas/openssl/openssl.sh is trying to pull https://www.openssl.org/source/$FILENAME.tar.gz with the filename openssl-1.0.2c.tar.gz

and https://www.openssl.org/source/openssl-1.0.2c.tar.gz is 404'ing with the correct URL being
https://www.openssl.org/source/old/1.0.2/openssl-1.0.2c.tar.gz

pull request to fix the script is here
#4186

However I'm getting the same error as @tallavi

./ostype.sh: No such file or directory

I commented out line 68 and 82 of apothecary because I'm on OSX and it's running fine, not a long term solution but at least poco can install

line 328 ANDROID_HOST="Darwin"

also threw an error and needed to be changed to

darwin-x86_64

@sterlingcrispin
Copy link
Contributor

same situation first

    java.lang.UnsatisfiedLinkError: Couldn't load neondetection from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/cc.openframeworks.android3DModelLoaderExample-1.apk"],nativeLibraryDirectories=[/data/app-lib/cc.openframeworks.android3DModelLoaderExample-1, /vendor/lib, /system/lib]]]: findLibrary returned null
            at java.lang.Runtime.loadLibrary(Runtime.java:358)
            at java.lang.System.loadLibrary(System.java:526)
            at cc.openframeworks.OFAndroid.<clinit>(OFAndroid.java:1028)
            at cc.openframeworks.android3DModelLoaderExample.OFActivity.onCreate(OFActivity.java:22)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5050)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
            at dalvik.system.NativeStart.main(Native Method)


08-05 01:20:08.866    8548-8548/cc.openframeworks.android3DModelLoaderExample D/dalvikvm﹕ Trying to load lib /data/app-lib/cc.openframeworks.android3DModelLoaderExample-1/libOFAndroidApp.so 0x4186caa8
08-05 01:20:08.866    8548-8548/cc.openframeworks.android3DModelLoaderExample E/dalvikvm﹕ dlopen("/data/app-lib/cc.openframeworks.android3DModelLoaderExample-1/libOFAndroidApp.so") failed: dlopen failed: cannot locate symbol "srand" referenced by "libOFAndroidApp.so"...
08-05 01:20:08.866    8548-8548/cc.openframeworks.android3DModelLoaderExample W/dalvikvm﹕ Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcc/openframeworks/OFAndroid;
08-05 01:20:08.866    8548-8548/cc.openframeworks.android3DModelLoaderExample D/AndroidRuntime﹕ Shutting down VM
08-05 01:20:08.866    8548-8548/cc.openframeworks.android3DModelLoaderExample W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415b1d58)
08-05 01:20:08.866    8548-8548/cc.openframeworks.android3DModelLoaderExample E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: cc.openframeworks.android3DModelLoaderExample, PID: 8548

    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "srand" referenced by "libOFAndroidApp.so"...
            at java.lang.Runtime.loadLibrary(Runtime.java:364)
            at java.lang.System.loadLibrary(System.java:526)
            at cc.openframeworks.OFAndroid.<clinit>(OFAndroid.java:1038)
            at cc.openframeworks.android3DModelLoaderExample.OFActivity.onCreate(OFActivity.java:22)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5050)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
            at dalvik.system.NativeStart.main(Native Method)

@sterlingcrispin
Copy link
Contributor

I tried building this against ndk-r10c , 10d, and 10e and getting nothing

@tallavi
Copy link

tallavi commented Aug 6, 2015

@sterlingcrispin, according to @arturoc, the problem is that poco and openssl needs to be rebuilt. But it fails. Can you try to follow his instructions too?

@sterlingcrispin
Copy link
Contributor

Yes I successfully rebuilt them, and boost, and tried many versions of the
NDK without success.
On Aug 6, 2015 8:32 AM, "tallavi" [email protected] wrote:

@sterlingcrispin https://github.com/sterlingcrispin, according to
@arturoc https://github.com/arturoc, the problem is that poco and
openssl needs to be rebuilt. But it fails. Can you try to follow his
instructions too?


Reply to this email directly or view it on GitHub
#4171 (comment)
.

@arturoc
Copy link
Member

arturoc commented Aug 6, 2015

@sterlingcrispin
Copy link
Contributor

@arturoc same errors about POCO and OPENSSL as @mhashmi first mentioned using NDK r10e --- the file in docs/android.md recommends I use r9d so I tried that but its looking for files that don't come with r9d
/bin/sh: /Users/sterlingcrispin/code/android-ndk-r9d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++: No such file or directory

@arturoc
Copy link
Member

arturoc commented Aug 7, 2015

can you try again? there where flags in other places that were making apothecary still compile those libraries with android-21. it's linking for me fine now with android-19 but don't have an android 4 device to test.

i've recreated the branch so there's no more libraries than necessary in the git history so you'll probably need to remove your local branch before pulling it again or pull it into a different one.

@sterlingcrispin
Copy link
Contributor

Hey @arturoc I downloaded that repo as a zip, set it up for ndk r10e, and got it building to a Nexus 7 tablet on 4.4.2 - thanks!

when I first tried to sync gradle and do a build it had a missing file at

toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++

I have a bunch of versions of the NDK and none have that g++ file in that directory, they're all in darwin-x86_64 , I just copied that folder and removed the _64, rebuilt and it works fine now.

@tallavi
Copy link

tallavi commented Aug 8, 2015

Sorry for disappearing. I had a mega-crisis over at my own project. I now tested and verified on both Android5 and Android4!

@mhashmi
Copy link
Contributor Author

mhashmi commented Aug 8, 2015

Thanks a lot @arturoc -- working perfectly here as well.

@mhashmi mhashmi closed this as completed Aug 8, 2015
@arturoc
Copy link
Member

arturoc commented Aug 9, 2015

@bilderbuchi to solve this i've change the android toolchain to 19 and now travis is failing. can you take a look?

@bilderbuchi
Copy link
Member

yeah I'll take a look

@bilderbuchi
Copy link
Member

btw, did the PR you made not fail/show that failure?

@bilderbuchi
Copy link
Member

@arturoc which version of the NDK is the appropriate one for toolchain 19?

@tallavi
Copy link

tallavi commented Aug 9, 2015

I switched to 10e when compiling/testing. 10b didn't compile.

@bilderbuchi
Copy link
Member

hm, we're on 10e right now (but a slimmed-down one because of travis memory problems). my suspicion is that toolchain 19 needs some file that it was ok to rip out in 21 (although I think we're not that aggressive)

@bilderbuchi
Copy link
Member

btw opened #4214 for any further discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants