Skia as a static library in android app: undefined references related to OpenGL

943 views
Skip to first unread message

Athos Bacchiocchi

unread,
Mar 26, 2013, 12:07:45 PM3/26/13
to skia-d...@googlegroups.com
hi, I'm again trying to use Skia as a static library in my android app.
I checked out revision 8363, successfully build static libraries using:

android_make -d arm -j2 BUILDTYPE=Release

Then I package the static libs located in
/trunk/out/config/android-arm/Release, using "merge_static_libs.py"
found in trunk/tools.

In particular I'm adding:
libskia_core.a
libskia_ports.a
libskia_opts.a
libskia_images.a
libskia_effects.a
libskia_utils.a
libskia_skgr.a
libskia_gr.a
libskia_xml.a
libfreetype.a
obj.target/gyp/libexpat.a

Then I add the library (libskia_custom.a) to my android.mk file, as a
prebuilt module, like this:

SKIA_FLAGS := -DSK_BUILD_FOR_ANDROID -DSK_BUILD_FOR_ANDROID_NDK \
-DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \
-DSK_SCALAR_IS_FLOAT -DSK_CAN_USE_FLOAT \
-DSK_USE_POSIX_THREADS \
-DSK_GAMMA_SRGB -DSK_GAMMA_APPLY_TO_A8\
-DSK_SUPPORT_GPU=1 -DGR_ANDROID_BUILD=1 \
-DSK_RELEASE -DGR_RELEASE=1 -DNDEBUG

SKIA_INCLUDES := $(SKIA_DIR)/include/gpu $(SKIA_DIR)/include/core \
$(SKIA_DIR)/include/effects
$(SKIA_DIR)/include/utils \
$(SKIA_DIR)/include/pipe
$(SKIA_DIR)/include/config \
$(SKIA_DIR)/include/images
$(SKIA_DIR)/include/lazy

include $(CLEAR_VARS)
LOCAL_PATH := $(SKIA_LOCAL_PATH)
LOCAL_MODULE := skiacustom_static
LOCAL_SRC_FILES := libskia_custom.a
LOCAL_LDLIBS := -lGLESv2 -lEGL
LOCAL_EXPORT_CFLAGS := $(SKIA_FLAGS)
LOCAL_EXPORT_C_INCLUDES := $(SKIA_INCLUDES)
include $(PREBUILT_STATIC_LIBRARY)

And then I list it as a dependency in my native module:

LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lOpenSLES -lm -landroid
LOCAL_STATIC_LIBRARIES += skiacustom_static

But I'm getting some undefined references, listed here:

/Users/athos/Documents/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
./obj/local/armeabi/libskia_custom.a(GrGLCreateNativeInterface_android.o):
in function
GrGLCreateNativeInterface():GrGLCreateNativeInterface_android.cpp(.text+0x640):
error: undefined reference to 'glBindVertexArrayOES'
/Users/athos/Documents/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
./obj/local/armeabi/libskia_custom.a(GrGLCreateNativeInterface_android.o):
in function
GrGLCreateNativeInterface():GrGLCreateNativeInterface_android.cpp(.text+0x688):
error: undefined reference to 'glDeleteVertexArraysOES'
/Users/athos/Documents/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
./obj/local/armeabi/libskia_custom.a(GrGLCreateNativeInterface_android.o):
in function
GrGLCreateNativeInterface():GrGLCreateNativeInterface_android.cpp(.text+0x6bc):
error: undefined reference to 'glGenVertexArraysOES'
/Users/athos/Documents/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
./obj/local/armeabi/libskia_custom.a(GrGLCreateNativeInterface_android.o):
in function
GrGLCreateNativeInterface():GrGLCreateNativeInterface_android.cpp(.text+0x7a0):
error: undefined reference to 'glFramebufferTexture2DMultisampleIMG'
/Users/athos/Documents/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
./obj/local/armeabi/libskia_custom.a(GrGLCreateNativeInterface_android.o):
in function
GrGLCreateNativeInterface():GrGLCreateNativeInterface_android.cpp(.text+0x7a4):
error: undefined reference to 'glRenderbufferStorageMultisampleIMG'

I believe these are related to OpenGL, as they are declared in gl2ext.h,
but since I included -lGLESv2 I thought I would be "covered". Did this
happen to anyone? Do you have any suggestion?

Thanks,
athos




petra Z

unread,
Mar 28, 2013, 9:41:21 PM3/28/13
to skia-d...@googlegroups.com
Hi,
I encountered the same problem as you. Do you have a method to solve the problem?
Please help me ,thanks a lot. 


在 2013年3月27日星期三UTC+8上午12时07分45秒,athos bacchiocchi写道:

Athos Bacchiocchi

unread,
Mar 29, 2013, 10:48:39 AM3/29/13
to skia-d...@googlegroups.com
I didn't solve yet, and due to the lack of time to explore the issue, I ended up using the the shared library compiled together with the sample app, specifically "libbench.so". It contains everything, surely also many useless stuff, but at least it works.

I guess that the functions causing the errors are not implemented in android's opengl, so one should find a way not to call them when compiling skia for android. I might be wrong, but it seems that all of them are inside an #ifdef that could help excluding them, but I don't remember which one, in this moment.

athos



Il 29/03/13 02.41, petra Z ha scritto:

Janez Zemva

unread,
Mar 29, 2013, 2:02:57 PM3/29/13
to skia-d...@googlegroups.com
Not necessarily unimplemented, you simply need to find them with egl and declare your own functions implementing them. They might be implemented, or not, depending on the graphics chip.

Example:

static PFNGLBINDVERTEXARRAYOESPROC pFNGLBINDVERTEXARRAYOESPROC;
static PFNGLDELETEVERTEXARRAYSOESPROC pFNGLDELETEVERTEXARRAYSOESPROC;
static PFNGLGENVERTEXARRAYSOESPROC pFNGLGENVERTEXARRAYSOESPROC;
static PFNGLISVERTEXARRAYOESPROC pFNGLISVERTEXARRAYOESPROC;

void glBindVertexArrayOES(GLuint array)
{
  (*pFNGLBINDVERTEXARRAYOESPROC)(array);
}

void glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays)
{
  (*pFNGLDELETEVERTEXARRAYSOESPROC)(n, arrays);
}

void glGenVertexArraysOES(GLsizei n, GLuint *arrays)
{
  (*pFNGLGENVERTEXARRAYSOESPROC)(n, arrays);
}

GLboolean glIsVertexArrayOES(GLuint array)
{
  return (*pFNGLISVERTEXARRAYOESPROC)(array);
}

Here you "implement" the missing functions via some functions. Android leaves this up to you. If you fiddle in C/C++ you need to also know details like these.



2013/3/29 Athos Bacchiocchi <at...@ntrack.com>

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/skia-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

petra Z

unread,
Mar 31, 2013, 10:58:48 PM3/31/13
to skia-d...@googlegroups.com
Hi,
    I wrote a very simple sample, used the same method with your. Link is ok, but when I executed the program, "canvas.drawLine( 0, 0, 100, 100, paint ); "was crash.
    can you help me?
    thanks a lot.
   

    SkGraphics::Init();

LOGI( "before draw line"  );
SkPaint paint;
paint.setARGB( 255, 0, 0, 0 );
LOGI( "create bitmap"  );
SkBitmap bitmap;
bitmap.setConfig( SkBitmap::kARGB_8888_Config, 400, 400 );
bitmap.allocPixels();
LOGI( "create canvas"  );

SkCanvas canvas( bitmap );
canvas.drawLine( 0, 0, 300, 300, paint );



在 2013年3月29日星期五UTC+8下午10时48分39秒,athos bacchiocchi写道:

Janez Zemva

unread,
Apr 1, 2013, 7:41:11 AM4/1/13
to skia-d...@googlegroups.com
If you mean the code sample I've sent. Of course it crashed: I didn't initialize the function pointers in it - that was an exercise left over to you. Check this site on how to proceed further:



2013/4/1 petra Z <petr...@gmail.com>

--
Reply all
Reply to author
Forward
0 new messages