链接库时的错误:Macos-Arm64构建,但试图与为MacOS-ARM构建的文件链接
我编译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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我面临类似的错误,切换节点版本有所帮助。我从14切换到16。
I was facing a similar error and switching node versions helped. I switched from 14 to 16.
如果您使用
brew
,也许您应该使用brew卸载binutils
...If you use
brew
, maybe you should usebrew uninstall binutils
...看起来clang(当调用
GCC
时)不喜欢与GNUAR
制作的静态库链接。虽然,如果您使用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 GNUar
.While, if you do the same with Apple's
ar
(and take care to deletea.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 yourPATH
when building ffmpeg, so the build will pick up the defaultar
.