“__mh_execute_header”的未定义符号
Undefined symbols for "__mh_execute_header"
我正在构建动态框架。我的框架与几个静态库链接。当它在带有示例应用程序的模拟器中为 运行 时,它工作正常。但是当我尝试使用示例应用程序将其存档时,我从链接器中收到以下错误。
Undefined symbols for architecture arm64:
"__mh_execute_header", referenced from:
那么什么是__mh_execute_header
,它在什么地方定义framework/library?
这是链接器定义的符号。从 <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
,而不是库、框架或包。
假设您的框架代码没有引用 _mh_execute_header
,那么引用可能来自您正在使用的静态库。然后仅在为 arm64 构建时。这对那些库来说是一件坏事,因为这意味着它们只能在可执行文件中使用,而不能在框架中使用。
您没有包括引用该符号的位置,但这可能会帮助您找出罪魁祸首。如果那些静态库来自第三方,那你就得去找他们帮忙解决了。
你应该更改密码
dladdr(&_mh_execute_header, &info);
至
dladdr(&_MH_EXECUTE_SYM, &info);
我正在构建动态框架。我的框架与几个静态库链接。当它在带有示例应用程序的模拟器中为 运行 时,它工作正常。但是当我尝试使用示例应用程序将其存档时,我从链接器中收到以下错误。
Undefined symbols for architecture arm64:
"__mh_execute_header", referenced from:
那么什么是__mh_execute_header
,它在什么地方定义framework/library?
这是链接器定义的符号。从 <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
,而不是库、框架或包。
假设您的框架代码没有引用 _mh_execute_header
,那么引用可能来自您正在使用的静态库。然后仅在为 arm64 构建时。这对那些库来说是一件坏事,因为这意味着它们只能在可执行文件中使用,而不能在框架中使用。
您没有包括引用该符号的位置,但这可能会帮助您找出罪魁祸首。如果那些静态库来自第三方,那你就得去找他们帮忙解决了。
你应该更改密码
dladdr(&_mh_execute_header, &info);
至
dladdr(&_MH_EXECUTE_SYM, &info);