gpt4 book ai didi

ios - ld : library not found for -lz clang: error

转载 作者:行者123 更新时间:2023-11-28 22:31:59 28 4
gpt4 key购买 nike

您好,我想在我的项目中使用 Google Maps API,我已经添加了 libz.dylib。当我在其他链接器标志中编写 -ObjC 以链接 Google Maps API 时,它工作正常但是当我删除此标志时 tan -lz library is not found 发现错误,所以请帮助我解决这个问题。

最佳答案

简答题
-ObjC 标志留在原处。


长答案
根据Google Maps SDK docs对于 iOS,-ObjC 标志是必需的。

In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.

如果您想了解更多信息,请参阅 Apple technical Q&A QA1490

问题出在静态库上的类别,默认不链接

Objective-C does not define linker symbols for each function (or method, in Objective-C) - instead, linker symbols are only generated for each class. If you extend a pre-existing class with categories, the linker does not know to associate the object code of the core class implementation and the category implementation. This prevents objects created in the resulting application from responding to a selector that is defined in the category.

显然 Google Maps API 在其静态库中使用类别,因此您需要 -ObjC 标志来更改链接器行为,如问答中所述

To resolve this issue, the target linking against the static library must pass the -ObjC option to the linker. This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.

关于ios - ld : library not found for -lz clang: error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17167446/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com