无法将 macOS-arm64 的库与 macOS-arm64 的可执行文件链接

Fuz*_*all 1 c++ g++ linker-errors static-libraries linker-warning


\n我在 **Monterey M1 MacBook** 上创建构建系统时遇到一些问题:\n

到目前为止,我有一个可用的 Makefile 来构建和链接库。
\n(简化:g++ -c所有 .cpp 文件转换为 .o 文件 \xe2\x86\x92 ar -r <.o files> libmyLibrary.a>\n
\xe2\x86\x92效果很好

\n

问题:
\n当我尝试构建一个使用所述libmyLibrary.a. 源文件的编译工作正常,但我收到以下(看似无意义的)链接器警告:

\n
ld: warning: ignoring file /Path/to/lib/libmyLibrary.a,\nbuilding for macOS-arm64 but attempting to link with file built for macOS-arm64\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x86\x92 我 ofc 然后得到一些Undefined symbols for architecture arm64: ... <stuff from library> referenced from: <stuff from executable>

\n

为与图书馆相同的目标而建设怎么会成为问题呢?

\n

Geo*_*gan 6

这是由于您的系统中安装了不兼容的版本所致arar在自制软件中 binutils 似乎被破坏了。llvm-ar这可以通过符号链接ar或使用系统来解决ar