error when import zlib in iOS: symbol(s) not found collect2: ld

前端 未结 2 1677
臣服心动
臣服心动 2020-12-04 15:59

I have included in my iphone application and the source code I was mocking up the sample code of Molecules provided by Brad Larson, however, when

相关标签:
2条回答
  • 2020-12-04 16:30

    Add libz to your project. To do this, follow these steps in Xcode:

    1. Open your project, select your project target and then click the blue project info icon on your toolbar (or press ⌘I)
      Example 1
    2. Click the + button in the lower-left corner of the screen to add a library, scroll down to the bottom of the library list and select libz.dylib; click the Add button.
      Example 2
    3. Once you've clicked add, you will see that the library name appears in oyur list of Linked Libraries. You will now be able to build your project without linking errors.
      Example 3

    You can use this same method to add any library from the list. If the library does not appear on the list, then you know that it is not part of the standard iPhone SDK and you may need to rethink your solution or build the library statically yourself and link your target to that (if even possible).

    0 讨论(0)
  • 2020-12-04 16:34

    In your Target's Build Settings tab, scroll down to the Other Linker Flags section and make sure -lz is in the field. This will link against the built-in zlib, and your error should go away.

    After changing the Linker Flags you must select Clean from the Product menu before building again.

    0 讨论(0)
提交回复
热议问题