using gtest and libjnigraphics: can't find libandroid_runtime.so

498 views
Skip to first unread message

Dmitry Suzdalev

unread,
Jun 22, 2011, 6:59:22 PM6/22/11
to andro...@googlegroups.com
Hello!

I just succesfully compiled gtest for ndk-r5b, trying to use it.

I created a standalone toolchain, then edited gtest's Makefile variables like this:

**************
# this file is in ${project}/test-ndk/make subdir
# gtest dir is ${project}/test-ndk/

MY_JNI_DIR = ../../jni/mylib

CXX = ../my-toolchain/bin/arm-linux-androideabi-g++
AR = ../my-toolchain/bin/arm-linux-androideabi-ar

# Flags passed to the preprocessor.
CPPFLAGS += -I$(GTEST_DIR)/include -I$(MY_JNI_DIR)

# Flags passed to the C++ compiler.
CXXFLAGS += -Wall -Wextra -mthumb -Os

LDFLAGS += -llog -ljnigraphics
# the rest is a standard gtest makefile (http://goo.gl/2zbSq)
*************

As can be told from above, my app uses libjnigraphics.
So I wrote a basic test case and now I get this when compiling with the above makefile:

../my-toolchain/bin/arm-linux-androideabi-g++ -I../gtest/include -I../../jni/mylib -Wall -Wextra -mthumb -Os -llog -ljnigraphics mylib.o mylib_test.o gtest_main.a -o myapp_test
../my-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: warning: libandroid_runtime.so, needed by ../my-toolchain/bin/../sysroot/usr/lib/libjnigraphics.so, not found (try using -rpath or -rpath-link)
../my-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: warning: libskia.so, needed by ../my-toolchain/bin/../sysroot/usr/lib/libjnigraphics.so, not found (try using -rpath or -rpath-link)
../my-toolchain/bin/../sysroot/usr/lib/libjnigraphics.so: undefined reference to `SkBitmap::unlockPixels() const'
../my-toolchain/bin/../sysroot/usr/lib/libjnigraphics.so: undefined reference to `GraphicsJNI::getNativeBitmap(_JNIEnv*, _jobject*)'
../my-toolchain/bin/../sysroot/usr/lib/libjnigraphics.so: undefined reference to `SkBitmap::lockPixels() const'

Only starting with NDK, so not sure where to dig from here.
I guess the problem is that ld path isn't set up correctly, but I can't figure out what the proper one would be. I did some grepping for android_runtime in $NDK dir, no hints found so far...

The very basic test with -ljnigraphics removed from LDFLAGS compiles fine and runs fine when copied to device.
Also jni/mylib which is actually linking to -ljnigraphics and uses Android.mk builds fine with ndk-build run from project dir.

Any hints?

David Turner

unread,
Jun 23, 2011, 7:31:30 AM6/23/11
to andro...@googlegroups.com
libjnigraphics is only available since API level 8, so you need to use --platform=android-8 (or higher) when calling make-standalone-toolchain.sh to ensure that it is in your sysroot.

Otherwise, you'll have to add a "-L$NDK/platforms/android-8/arch-arm/usr/lib -ljnigraphics" to your link command.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

Dmitry Suzdalev

unread,
Jun 23, 2011, 1:07:06 PM6/23/11
to andro...@googlegroups.com
Thanks, David! 

But I did use that (android-8) when creating my toolchain.
I just double checked - the libjnigraphics.so exists in a sysroot of my generated toolchain.

And actually if you look again at the output I provided above: it doesn't say that ljnigraphics not found - it first issues a warning about libandroid_runtime.so not found (referenced from ljnigraphics) and then an error about unresovled functions from libskia....

What I do not know is where to find these libs to add them to ldpath...
Reply all
Reply to author
Forward
0 new messages