In Android Use libView.so, why not have cpp Code?

263 views
Skip to first unread message

Mingyue 郭

unread,
Apr 18, 2017, 8:59:19 AM4/18/17
to skia-discuss
In Skia folder:

It is a simple Example in Android use skia lib ? 
In java code I found native function,  But  I can not found the function definition (C++)? 
Where is it ? Or How I should use it?

In the old skia, There is a helloWorld Example In skia\platform_tools\android\examples\hello_skia_app; I build it and use new skia lib(libskia.so), when run, 
throw out dlopen failed!

Jim Van Verth

unread,
Apr 18, 2017, 9:49:44 AM4/18/17
to skia-discuss
The C++ code for the Viewer is in tools/viewer, and I believe the remaining C++ code for the Android interface is in tools/viewer/sk_app/android. Instructions for building the Viewer can be found at https://skia.org/user/sample/viewer.

--
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 https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Mingyue 郭

unread,
Apr 19, 2017, 12:31:52 AM4/19/17
to skia-discuss
thinks. It looked complicated for me. 
And:
I use libskia.a, it is ok. 
But  the file libskia.a size is a big(57.7MB).

在 2017年4月18日星期二 UTC+8下午9:49:44,Jim Van Verth写道:

Jim Van Verth

unread,
Apr 19, 2017, 9:03:49 AM4/19/17
to skia-discuss
I'm not sure if there's a build setting with GN, but you can use 'strip' (https://linux.die.net/man/1/strip) to remove the extra symbols from libskia.a. That should reduce the size considerably.

Mike Klein

unread,
Apr 19, 2017, 9:07:08 AM4/19/17
to skia-discuss
If you're worried about build size, the best first thing to do is make sure you have set is_official_build=true in GN.  You can learn more by reading the first section of https://skia.org/user/build.

Mingyue 郭

unread,
Apr 19, 2017, 10:25:40 PM4/19/17
to skia-discuss
I had do it,But I do not konw Why they cannot found many header  file  like this:

mingyue@ubuntu:~/git/skia$ bin/gn gen out/arm-4    --args='ndk="/home/mingyue/android-ndk-r14b" target_cpu="arm" is_official_build=true'
Done. Made 36 targets from 25 files in 32ms
mingyue@ubuntu:~/git/skia$ ninja -C out/arm-4
ninja: Entering directory `out/arm-4'
[85/806] compile ../../src/ports/SkFontMgr_android_parser.cpp
FAILED: /home/mingyue/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -MMD -MF obj/src/ports/fontmgr_android.SkFontMgr_android_parser.o.d -DNDEBUG -DSK_GAMMA_APPLY_TO_A8 -DSK_INTERNAL -DSK_GAMMA_EXPONENT=1.4 -DSK_GAMMA_CONTRAST=0.0 -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 -DSK_ENABLE_DISCRETE_GPU -DSKIA_IMPLEMENTATION=1 -I../../include/android -I../../include/c -I../../include/codec -I../../include/config -I../../include/core -I../../include/effects -I../../include/gpu -I../../include/gpu/gl -I../../include/pathops -I../../include/ports -I../../include/svg -I../../include/utils -I../../include/utils/mac -I/include -I../../include/private -I../../src/c -I../../src/codec -I../../src/core -I../../src/effects -I../../src/effects/gradients -I../../src/fonts -I../../src/image -I../../src/images -I../../src/lazy -I../../src/opts -I../../src/pathops -I../../src/pdf -I../../src/ports -I../../src/sfnt -I../../src/sksl -I../../src/utils -I../../src/utils/win -I../../src/xml -I../../third_party/etc1 -I../../third_party/gif -I../../src/gpu -fstrict-aliasing -fPIC -Werror -march=armv7-a -mfpu=neon -mthumb --sysroot=/home/mingyue/android-ndk-r14b/platforms/android-18/arch-arm --target=arm-linux-androideabi -B/home/mingyue/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin -Wall -Wextra -Winit-self -Wpointer-arith -Wsign-compare -Wvla -Wno-deprecated-declarations -Wno-maybe-uninitialized -Weverything -Wno-unknown-warning-option -Wno-cast-align -Wno-conditional-uninitialized -Wno-conversion -Wno-disabled-macro-expansion -Wno-documentation -Wno-documentation-unknown-command -Wno-double-promotion -Wno-exit-time-destructors -Wno-float-conversion -Wno-float-equal -Wno-format-nonliteral -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-pedantic -Wno-reserved-id-macro -Wno-shadow -Wno-shift-sign-overflow -Wno-sign-conversion -Wno-signed-enum-bitfield -Wno-switch-enum -Wno-undef -Wno-unreachable-code -Wno-unreachable-code-break -Wno-unreachable-code-return -Wno-unused-macros -Wno-unused-member-function -Wno-covered-switch-default -Wno-deprecated -Wno-implicit-fallthrough -Wno-missing-noreturn -Wno-old-style-cast -Wno-padded -Wno-unused-parameter -O3 -fdata-sections -ffunction-sections -std=c++11 -isystem/home/mingyue/android-ndk-r14b/sources/android/support/include -isystem/home/mingyue/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem/home/mingyue/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -fno-exceptions -fno-rtti -Wnon-virtual-dtor -Wno-abstract-vbase-init -Wno-weak-vtables -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-undefined-func-template -c ../../src/ports/SkFontMgr_android_parser.cpp -o obj/src/ports/fontmgr_android.SkFontMgr_android_parser.o
../../src/ports/SkFontMgr_android_parser.cpp:21:10: fatal error: 'expat.h' file not found
#include <expat.h>
         ^
1 error generated.
[85/806] compile ../../src/ports/SkGlobalInitialization_default.cpp
ninja: build stopped: subcommand failed.

I can found the expat.h in third_party/externals folder ,so I change the SkGlobalInitialization_default.cpp the include "../../third_party/externals/expat/lib/expat.h", The error can be solved。
But then continue, there have :
[346/806] compile ../../src/codec/SkPngCodec.cpp
FAILED: /home/mingyue/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -MMD -MF obj/src/codec/png.SkPngCodec.o.d -DNDEBUG -DSK_GAMMA_APPLY_TO_A8 -DSK_INTERNAL -DSK_GAMMA_EXPONENT=1.4 -DSK_GAMMA_CONTRAST=0.0 -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 -DSK_ENABLE_DISCRETE_GPU -DSKIA_IMPLEMENTATION=1 -DSK_HAS_PNG_LIBRARY -I../../include/android -I../../include/c -I../../include/codec -I../../include/config -I../../include/core -I../../include/effects -I../../include/gpu -I../../include/gpu/gl -I../../include/pathops -I../../include/ports -I../../include/svg -I../../include/utils -I../../include/utils/mac -I/include -I../../include/private -I../../src/c -I../../src/codec -I../../src/core -I../../src/effects -I../../src/effects/gradients -I../../src/fonts -I../../src/image -I../../src/images -I../../src/lazy -I../../src/opts -I../../src/pathops -I../../src/pdf -I../../src/ports -I../../src/sfnt -I../../src/sksl -I../../src/utils -I../../src/utils/win -I../../src/xml -I../../third_party/etc1 -I../../third_party/gif -I../../src/gpu -fstrict-aliasing -fPIC -Werror -march=armv7-a -mfpu=neon -mthumb --sysroot=/home/mingyue/android-ndk-r14b/platforms/android-18/arch-arm --target=arm-linux-androideabi -B/home/mingyue/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin -Wall -Wextra -Winit-self -Wpointer-arith -Wsign-compare -Wvla -Wno-deprecated-declarations -Wno-maybe-uninitialized -Weverything -Wno-unknown-warning-option -Wno-cast-align -Wno-conditional-uninitialized -Wno-conversion -Wno-disabled-macro-expansion -Wno-documentation -Wno-documentation-unknown-command -Wno-double-promotion -Wno-exit-time-destructors -Wno-float-conversion -Wno-float-equal -Wno-format-nonliteral -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-pedantic -Wno-reserved-id-macro -Wno-shadow -Wno-shift-sign-overflow -Wno-sign-conversion -Wno-signed-enum-bitfield -Wno-switch-enum -Wno-undef -Wno-unreachable-code -Wno-unreachable-code-break -Wno-unreachable-code-return -Wno-unused-macros -Wno-unused-member-function -Wno-covered-switch-default -Wno-deprecated -Wno-implicit-fallthrough -Wno-missing-noreturn -Wno-old-style-cast -Wno-padded -Wno-unused-parameter -O3 -fdata-sections -ffunction-sections -std=c++11 -isystem/home/mingyue/android-ndk-r14b/sources/android/support/include -isystem/home/mingyue/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem/home/mingyue/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -fno-exceptions -fno-rtti -Wnon-virtual-dtor -Wno-abstract-vbase-init -Wno-weak-vtables -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-undefined-func-template -c ../../src/codec/SkPngCodec.cpp -o obj/src/codec/png.SkPngCodec.o
../../src/codec/SkPngCodec.cpp:24:10: fatal error: 'png.h' file not found
#include "png.h"

It seems that the header file can not be referenced correctly.I do not want to change the include one by one beacuse there have Hundreds of files.
I alse set  like this:export C_INCLUDE_PATH="/home/mingyue/git/skia/third_party/externals:$C_INCLUDE_PATH",bout it can not working.



在 2017年4月19日星期三 UTC+8下午9:07:08,Mike Klein写道:

Mike Klein

unread,
Apr 19, 2017, 11:42:29 PM4/19/17
to skia-discuss
This is intentional... when you set is_official_build=true, you are disabling the versions of several test libraries we build from source in the default is_official_build=false build mode.

You need to decide whether you want to build Skia with support for these libraries, and how you want to provide it.  If you don't want them, you'll need to turn them off using skia_use_<something>=false where <something> is the name of the library to disable.

The default with is_official_build=true is that we'll try to build and link against the libraries found on ordinary system include and library paths (like /usr/include, /usr/lib).  You can use extra_cflags and extra_ldflags to point your compiler at the libraries you want (using -Isomething and -Lsomething).  I'm not familiar with C_INCLUDE_PATH, but if your compiler supports that it should work fine.

Alternatively, if you really want to use the versions of these libraries that we do not at all support and just happened to check out for our convenience in testing, you can set skia_use_system_<something>=false to go back to building that library from source.

Mingyue 郭

unread,
Apr 20, 2017, 10:06:39 PM4/20/17
to skia-discuss
It explains the matter. Thinks.

在 2017年4月20日星期四 UTC+8上午11:42:29,Mike Klein写道:

Volodymyr B

unread,
Jan 6, 2018, 7:06:52 PM1/6/18
to skia-discuss
thank you Mike!

please consider add this info to skia build instruction.

Mike Klein

unread,
Jan 7, 2018, 8:33:06 AM1/7/18
to skia-d...@googlegroups.com
I think this already there, the very first section on skia.org/user/build... is that missing anything?
Reply all
Reply to author
Forward
0 new messages