Cannot make libskia.so work

224 views
Skip to first unread message

宋子明

unread,
Jan 25, 2015, 9:13:20 AM1/25/15
to skia-d...@googlegroups.com
Hi, im trying to build libskia.so and use it in my application. I can build the shared object successfully, but when I link my program against it, I got an error saying:

/tmp/ccRxLGCL.o: In function `SkStrFind(char const*, char const*)':
main.cpp:(.text+0x136): undefined reference to `SkToS32(long)'
collect2: error: ld returned 1 exit status

That libskia.so was built in release mode, and I checked src/core/SkDebug.cpp and found that SkToS32 only present in debug mode. I didn't set the SK_DEBUG macro but my program still trying to use that function.

If I build the shared object in debug mode, then I got a compile error when building the library:

GYP_GENERATORS environment variable not set, using default
GYP_GENERATORS is "ninja"
Updating projects from gyp files...
ninja -C out/Debug most
ninja: Entering directory `out/Debug'
[104/1024] LINK skpdiff
FAILED: c++ -m64 -pie -Wl,-rpath=\$ORIGIN/lib/ -Wl,-rpath-link=lib/ -o skpdiff -Wl,--start-group obj/tools/skpdiff/skpdiff.skpdiff_main.o obj/tools/skpdiff/skpdiff.SkDiffContext.o obj/tools/skpdiff/skpdiff.SkImageDiffer.o obj/tools/skpdiff/skpdiff.SkPMetric.o obj/tools/skpdiff/skpdiff.skpdiff_util.o obj/tools/skpdiff/skpdiff.SkDifferentPixelsMetric_cpu.o obj/gyp/libflags.a obj/gyp/libpicture_utils.a -Wl,--end-group lib/libskia.so -lrt -lpng -lz -lgif
/usr/bin/ld: obj/tools/skpdiff/skpdiff.SkDiffContext.o: undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[104/1024] LINK skhello
FAILED: c++ -m64 -pie -Wl,-rpath=\$ORIGIN/lib/ -Wl,-rpath-link=lib/ -o skhello -Wl,--start-group obj/tools/skhello.skhello.o obj/gyp/libflags.a libskia_pdf.a obj/gyp/libskflate.a -Wl,--end-group lib/libskia.so -lpng -lz -lgif
/usr/bin/ld: libskia_pdf.a(pdf.SkPDFStream.o): undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[104/1024] LINK render_pdfs
FAILED: c++ -m64 -pie -Wl,-rpath=\$ORIGIN/lib/ -Wl,-rpath-link=lib/ -o render_pdfs -Wl,--start-group obj/tools/render_pdfs.render_pdfs_main.o obj/gyp/libflags.a libskia_pdf.a obj/gyp/libpicture_utils.a obj/gyp/libproc_stats.a obj/gyp/libskflate.a -Wl,--end-group lib/libskia.so -lpng -lz -lgif
/usr/bin/ld: libskia_pdf.a(pdf.SkPDFStream.o): undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[104/1024] LINK lua_app
ninja: build stopped: subcommand failed.
make: *** [most] Error 1

I wonder if there is any mistake in the way I build the libskia.so, which is:

./gyp_skia
export GYP_DEFINES="skia_shared_lib=1"
make BUILDTYPE=Release -j4
(then copy out/Release/lib/libskia.so to my project source folder along with skia's include directory)
(compile my program using:)
g++ main.cpp -o test -I include/core -I include/config -L. -lskia

Thank in advance

Menci

unread,
Feb 28, 2015, 12:20:18 AM2/28/15
to skia-d...@googlegroups.com
你系统是32还是64?他编译的是64位的Skia
Is your system 32-bits or 64-bits?It was compiling the 64-bits Skia

在 2015年1月25日星期日 UTC+8下午10:13:20,宋子明写道:

宋子明

unread,
Mar 1, 2015, 1:22:51 AM3/1/15
to skia-d...@googlegroups.com
我用的是64位Ubuntnu 14.04.1

Im using ubuntu 14.04.1 64 bit.

Menci

unread,
Mar 1, 2015, 2:36:55 AM3/1/15
to skia-d...@googlegroups.com
我编译静态库成功了,动态库我没试过,你更新下系统试试,我在Fedora21 x86 clang3.5环境下编译静态库成功了
它的命令行里好像没有链接pthread库......你给加上试试

在 2015年3月1日星期日 UTC+8下午2:22:51,宋子明写道:
Reply all
Reply to author
Forward
0 new messages