链接库时的错误:Macos-Arm64构建,但试图与为MacOS-ARM构建的文件链接

发布于 2025-02-04 08:52:17 字数 2412 浏览 2 评论 0原文

我编译FFMPEG和编译器输出以下错误。

ld: warning: ignoring file libavdevice/libavdevice.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libavfilter/libavfilter.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libswresample/libswresample.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libswscale/libswscale.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libavutil/libavutil.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file libpostproc/libpostproc.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file libavformat/libavformat.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libavcodec/libavcodec.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )

我不明白为什么MacOS-ARM64无法链接到MacOS-ARM64

ARM64对象文件不应该链接到ARM64静态库吗?


我正在使用M1 MacBook工作,并使用以下命令配置FFMPEG。

../configure --cc=/usr/bin/clang --prefix=/opt/ffmpeg --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband  --enable-libwebp --enable-libx264 --enable-libx265  --enable-libzimg --enable-libzmq  --enable-version3 --pkg-config-flags=--static --disable-ffplay --extra-cflags="-I/opt/homebrew/include" --extra-cxxflags="-I/opt/homebrew/include" --extra-ldflags="-L/opt/homebrew/lib"

完整输出在这里: https://pastebin.com/u9qntitu

I compile the ffmpeg and compiler outputs the following errors.

ld: warning: ignoring file libavdevice/libavdevice.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libavfilter/libavfilter.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libswresample/libswresample.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libswscale/libswscale.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libavutil/libavutil.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file libpostproc/libpostproc.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file libavformat/libavformat.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file libavcodec/libavcodec.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )

I don't understand why macOS-arm64 cannot link to macOS-arm64.

Shouldn't an arm64 object file link to arm64 static libraries?


I'm working on an M1 macbook, and configure the ffmpeg with the following commands.

../configure --cc=/usr/bin/clang --prefix=/opt/ffmpeg --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband  --enable-libwebp --enable-libx264 --enable-libx265  --enable-libzimg --enable-libzmq  --enable-version3 --pkg-config-flags=--static --disable-ffplay --extra-cflags="-I/opt/homebrew/include" --extra-cxxflags="-I/opt/homebrew/include" --extra-ldflags="-L/opt/homebrew/lib"

The full output is here: https://pastebin.com/u9QNTitu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

乖乖公主 2025-02-11 08:52:18

我面临类似的错误,切换节点版本有所帮助。我从14切换到16。

I was facing a similar error and switching node versions helped. I switched from 14 to 16.

糖粟与秋泊 2025-02-11 08:52:17

如果您使用brew,也许您应该使用brew卸载binutils ...

If you use brew, maybe you should use brew uninstall binutils...

纵性 2025-02-11 08:52:17

看起来clang(当调用GCC时)不喜欢与GNU AR制作的静态库链接。

% echo "int main() { }" > a.c
% gcc -c a.c
% /opt/homebrew/opt/binutils/bin/ar rcs a.a a.o
% gcc a.a
ld: warning: ignoring file a.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
...

虽然,如果您使用Apple的ar进行操作(并小心删除aa,由Binutils创建,首先),则可以正确链接。在这种情况下,错误消息只是误导了。这就是为什么 @Peng的答案朝着正确的方向。没有必要实际删除binutil,只是在构建FFMPEG时就没有在PATH中没有它,因此构建将拾取默认的ar

Looks like Clang (when invoked as gcc) does not like linking with static libraries made by GNU ar.

% echo "int main() { }" > a.c
% gcc -c a.c
% /opt/homebrew/opt/binutils/bin/ar rcs a.a a.o
% gcc a.a
ld: warning: ignoring file a.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
...

While, if you do the same with Apple's ar (and take care to delete a.a, created by binutils, first), it links correctly. The error message is just misleading in this case. This is why @Peng's answer is in the right direction. There is no need to actually remove binutils, just don't have it in your PATH when building ffmpeg, so the build will pick up the default ar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文