63

I'm doing native iOS application using SUP.As per documentation; i have included the library and given the link path in Xcode. While building getting following error:

Undefined symbols for architecture i386:
  "_deflate", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in         libMo.a(tlplatcompress.o)
  "_deflateEnd", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in libMo.a(tlplatcompress.o)
  "_deflateInit_", referenced from:
      StartCompression(enumCompressOperation, unsigned char, long (*)(void*, void*, long), void*, void**) in libMo.a(tlplatcompress.o)
  "_deflateParams", referenced from:
      StartCompression(enumCompressOperation, unsigned char, long (*)(void*, void*, long), void*, void**) in libMo.a(tlplatcompress.o)
  "_inflate", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in libMo.a(tlplatcompress.o)
  "_inflateEnd", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in libMo.a(tlplatcompress.o)
  "_inflateInit_", referenced from:
      StartCompression(enumCompressOperation, unsigned char, long (*)(void*, void*,  long), void*, void**) in libMo.a(tlplatcompress.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please help me how to solve this error.I'm new to native iOS development using SUP.

Thanks.

bapi
  • 1,903
  • 10
  • 34
  • 59
  • possible duplicate of [Error:Apple Mach-O Linker (Id) Warning](http://stackoverflow.com/questions/7752127/errorapple-mach-o-linker-id-warning) – Martin R Aug 05 '13 at 08:25
  • 3
    Got sol from here(now no build error): http://stackoverflow.com/questions/7752127/errorapple-mach-o-linker-id-warning Thanks. – bapi Aug 05 '13 at 09:02

4 Answers4

154

I also had a same error.

Add libz.dylib to framework from the target -> Build Phases tab -> Link Binaries With Libraries,

hope that will work for you.

Note: If libz.dylib not found, try adding libz.tbd

Dhaval H. Nena
  • 3,992
  • 1
  • 37
  • 50
44

Starting with Xcode 7, instead of adding libz.dylib, you should do this:

  • Go to the project Build Settings tab
  • Search for Other Linker Flags
  • Add -lz as a linker flag (see screenshot)
  • In the Product menu, select Clean before building again

lz link option

Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110
  • 1
    Thank you so much, you saved my life :) – Sagar In Jan 04 '16 at 06:11
  • getting the same issue in Xcode 8.2.1 for adding a custom framework in a application .... pleasehelp – SHASHANK Feb 28 '17 at 12:15
  • 2
    Please add an explanation as to why this resolves the problem. – Chuck Krutsinger Jul 07 '17 at 16:45
  • 2
    @ChuckKrutsinger I know that the manual for `ld` explains the `-l[x]` flag tells the linker how to find the `lib[x].dylib` (in this case, libz.dylib). Somebody who understands this issue better than me should add an explanation. I just stumbled across the solution after other answers here didn't work, and posted what I did. – Abhi Beckert Jul 25 '17 at 20:55
  • still true for Xcode 9. Either use flags or add the framework would work. – Wingzero Feb 01 '18 at 06:50
19

Undefined symbols for architecture i386:

  "_deflate", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in         libMo.a(tlplatcompress.o)
  "_deflateEnd", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in libMo.a(tlplatcompress.o)
  "_deflateInit_", referenced from:
      StartCompression(enumCompressOperation, unsigned char, long (*)(void*, void*, long), void*, void**) in libMo.a(tlplatcompress.o)
  "_deflateParams", referenced from:
      StartCompression(enumCompressOperation, unsigned char, long (*)(void*, void*, long), void*, void**) in libMo.a(tlplatcompress.o)
  "_inflate", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in libMo.a(tlplatcompress.o)
  "_inflateEnd", referenced from:
      PlatCompress(enumCompressOperation, CompressCookie*, void*, long) in libMo.a(tlplatcompress.o)
  "_inflateInit_", referenced from:
      StartCompression(enumCompressOperation, unsigned char, long (*)(void*, void*,  long), void*, void**) in libMo.a(tlplatcompress.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I had also the same problem,I think you didn't include the libz.dylib library.

To do so:

  1. go to target section
  2. Build Phases tab
  3. Link Binaries With Libraries
  4. click on + button
  5. search libz.dylib
  6. clcik on add button.
ekostadinov
  • 6,880
  • 3
  • 29
  • 47
asheesh Verma
  • 404
  • 6
  • 17
12

1.go to target section

2.Build Phases tab

3.Link Binaries With Libraries

4.click on + button

5.search libz.tbd (or libz.dylib)

6.click on add button.

Vinoth Anandan
  • 1,157
  • 17
  • 15