gpt4 book ai didi

ios - "__mh_execute_header"的 undefined symbol

转载 作者:行者123 更新时间:2023-12-03 16:20:05 24 4
gpt4 key购买 nike

我正在构建一个动态框架。我的框架与几个静态库链接。当它在带有示例应用程序的模拟器中运行时,它工作正常。但是当我尝试使用示例应用程序对其进行存档时,我从链接器中收到以下错误。

Undefined symbols for architecture arm64:
"__mh_execute_header", referenced from:

那么什么是__mh_execute_header以及它是在什么框架/库中定义的?

最佳答案

它是链接器定义的符号。从顶部<mach-o/ldsyms.h> :

This file describes the link editor defined symbols. The semantics of a link editor symbol is that it is defined by the link editor only if it is referenced and it is an error for the user to define them (see the man page ld(1)). The standard UNIX link editor symbols: __end, __etext and __edata are not not supported by the Apple Mach-O link editor. These symbols are really not meaningful in a Mach-O object file and the link editor symbols that are supported (described here) replace them. In the case of the standard UNIX link editor symbols the program can use the symbol __mh_execute_header and walk the load commands of it's program to determine the ending (or beginning) of any section or segment in the program. Note that the compiler prepends an underbar to all external symbol names coded in a high level language. Thus in 'C' names are coded without an underbar and symbol names in the symbol table have an underbar. There are two cpp macros for each link editor defined name in this file. The macro with a leading underbar is the symbol name and the one without is the name as coded in 'C'.

具体符号__mh_execute_header进一步描述(强调):

The value of the link editor defined symbol [__mh_execute_header] is the address of the mach header in a Mach-O executable file type. It does not appear in any file type other than a MH_EXECUTE file type. The type of the symbol is absolute as the header is not part of any section.

因此,链接器仅定义 __mh_execute_header当链接可执行文件时,而不是库、框架或 bundle 时。

假设您的框架代码未引用_mh_execute_header ,那么引用可能来自您正在使用的静态库。然后仅在为arm64 构建时。这对于这些库来说是一件坏事,因为这意味着它们只能在可执行文件中使用,而不能在框架中使用。

您没有包含引用该符号的位置,但这可能会帮助您识别罪魁祸首。如果这些静态库来自第三方,那么您将不得不向他们寻求帮助来解决该问题。

关于ios - "__mh_execute_header"的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54368717/

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