Apple 链接器警告“ld:警告:-未定义错误已弃用”

问题描述 投票:0回答:1

当前在我们针对 macOS 的 C++ 版本中看到此链接器警告:

[build] [430/431  99% :: 9.484] Linking CXX executable foobar
[build] ld: warning: -undefined error is deprecated

我们在

CMakeLists.txt
中设置此链接器选项:

add_link_options("-Wl,-undefined,error")

ld
链接器的手册页也没有提供有用的信息:

-undefined treatment
    Specifies how undefined symbols are to be treated. Options are: error, warning, suppress,
    or dynamic_lookup.  The default is error. Note: dynamic_lookup that depends on lazy binding
    will not work with chained fixups.

我不清楚为什么这已被弃用以及我应该采取的行动。

c++ macos ld
1个回答
1
投票

XCode 15 包含全新的 linker 实现。因此,一些标志已被弃用。

由于编译器和全新链接器的改进,项目构建速度更快,针对 Apple 芯片的多核架构进行了优化。

正如您在 ld 手册中提到的,

-undefined
的默认处理是
error
- 您可以简单地在 cmake 中取消此显式标志设置。

另请记住,您仍然可以使用标志

-ld64
显式请求旧/经典链接器。

© www.soinside.com 2019 - 2024. All rights reserved.