Mac OS X Xcode project fails on linker

249 views
Skip to first unread message

Václav Luštěk

unread,
Nov 12, 2018, 2:57:31 PM11/12/18
to skia-discuss
Hello, over the past few days I've been trying to get Skia running on Mac OS X in Xcode to see if it could work in our Swift project. I've managed to build a static library, get Xcode to see it, but now I am getting linker errors that I cannot figure out how to fix.

Here are the steps I've taken:
  1. Clone the Skia repository (I've used the chrome/m70 branch)
  2. Sync dependencies with
    python tools/git-sync-deps
  3. Create .o files with

    bin/gn gen out/Release --args='is_official_build=true is_debug=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_icu=false

  4. Create libskia.a with

    ninja -C out/Release

  5. Create a new Xcode command line tool project in C++
    1. Copy the libskia.a into the project folder
    2. Copy the skia/include folder into the project folder
    3. Setup the build settings by following this guide https://stackoverflow.com/a/44328298 (added Core frameworks, Library search paths, Header search paths and Other linker flags)
    4. The project now builds fine
    5. Add test code into the main function
    6. The project doesn't build anymore once I reference anything from the Skia library, failing on
      linker command failed with exit code 1
Here's the full error message:

Undefined symbols for architecture x86_64:

 "_adler32", referenced from:

     _png_icc_set_sRGB in libskia.a(libpng.png.o)

 "_compress2", referenced from:

     dng_image_writer::WriteData(dng_host&, dng_ifd const&, dng_stream&, dng_pixel_buffer&, AutoPtr<dng_memory_block>&) in libskia.a(dng_sdk.dng_image_writer.o)

 "_crc32", referenced from:

     _png_reset_crc in libskia.a(libpng.png.o)

     _png_calculate_crc in libskia.a(libpng.png.o)

     _png_icc_set_sRGB in libskia.a(libpng.png.o)

 "_deflate", referenced from:

     _png_compress_IDAT in libskia.a(libpng.pngwutil.o)

     _png_text_compress in libskia.a(libpng.pngwutil.o)

 "_deflateEnd", referenced from:

     _png_destroy_write_struct in libskia.a(libpng.pngwrite.o)

     _png_deflate_claim in libskia.a(libpng.pngwutil.o)

 "_deflateInit2_", referenced from:

     _png_deflate_claim in libskia.a(libpng.pngwutil.o)

 "_deflateReset", referenced from:

     _png_deflate_claim in libskia.a(libpng.pngwutil.o)

 "_inflate", referenced from:

     _png_zlib_inflate in libskia.a(libpng.pngrutil.o)

     _png_handle_iCCP in libskia.a(libpng.pngrutil.o)

     _png_read_IDAT_data in libskia.a(libpng.pngrutil.o)

    (maybe you meant: _png_zlib_inflate)

 "_inflateEnd", referenced from:

     _png_destroy_read_struct in libskia.a(libpng.pngread.o)

 "_inflateInit2_", referenced from:

     _png_inflate_claim in libskia.a(libpng.pngrutil.o)

 "_inflateReset", referenced from:

     _png_reset_zstream in libskia.a(libpng.png.o)

     _png_decompress_chunk in libskia.a(libpng.pngrutil.o)

 "_inflateReset2", referenced from:

     _png_inflate_claim in libskia.a(libpng.pngrutil.o)

 "_inflateValidate", referenced from:

     _png_inflate_claim in libskia.a(libpng.pngrutil.o)

 "_uncompress", referenced from:

     dng_read_image::ReadTile(dng_host&, dng_ifd const&, dng_stream&, dng_image&, dng_rect const&, unsigned int, unsigned int, unsigned int, AutoPtr<dng_memory_block>&, AutoPtr<dng_memory_block>&, AutoPtr<dng_memory_block>&) in libskia.a(dng_sdk.dng_read_image.o)

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


If I understand it correctly, the libpng and dng_sdk libraries haven't been compiled for x86_64 architecture. I've tried passing target_cpu="x64" or target_cpu="x86_64" to the gen command, but it doesn't help. I've also tried removing
 skia_use_system_libpng=false and updating the libpng library on my system, but that also fails on the linker, although with different errors (still libpng related).

Any help would be greatly appreciated! Thanks

L2000

unread,
Mar 24, 2023, 3:33:08 AM3/24/23
to skia-discuss
Hi
    Did you find solution to this problem as i am facing the same.

craste...@gmail.com

unread,
Mar 24, 2023, 5:46:11 AM3/24/23
to skia-discuss
I forget.
Does "python tools/git-sync-deps" build the third party libraries?


L2000

unread,
Mar 24, 2023, 6:15:06 AM3/24/23
to skia-discuss
yes

L2000

unread,
Apr 28, 2023, 2:20:48 AM4/28/23
to skia-discuss
It is because of missing libz.dylib (or libz.tbd) library.Try adding it.It got resolved after adding this library.
Reply all
Reply to author
Forward
0 new messages