[MacOS 10.15.5 ] building for macOS-x86_64 but attempting to link with file built for macOS-x86

在编译M4BISON的时候碰到这个错误,经过排查后发现,是MACOS升级后,默认的编译配置被/usr/local/bin的给覆盖了,导致编译时使用了错误的ld ar ranlib gcc

升级后的:
which ld ar ranlib gcc

/usr/bin/ld
/usr/local/bin/ar
/usr/local/bin/ranlib
/usr/bin/gcc

调整一下PATH路径中的先后关系,先使用/usr/bin路径下的

sudo  vim /etc/paths

调整为如下顺序

/usr/bin
/bin
/usr/local/bin
/usr/sbin
/sbin
修改后:
which ld ar ranlib gcc

/usr/bin/ld
/usr/bin/ar
/usr/bin/ranlib
/usr/bin/gcc

经过上述,就可以正确编译了。

引用

  • https://gowa.club/macOS/%E5%9C%A8macOS-Mojave%E4%B8%8A%E7%BC%96%E8%AF%91Lua%E5%A4%B1%E8%B4%A5%E7%9A%84%E7%BB%8F%E5%8E%86.html

你可能感兴趣的:([MacOS 10.15.5 ] building for macOS-x86_64 but attempting to link with file built for macOS-x86)