Why do I get cc1plus: error: unrecognized command line option “-arch”?

懵懂的女人 提交于 2019-11-29 06:14:34

The -arch option is part of the Apple extensions to gcc. You need to use the gcc supplied by Apple's Developer Tools, Xcode.

The -arch option is only in the Apple-provided version of gcc. Change CFLAGS (which might be set via your environment, your makefile, or your configure options) so it uses -march or -m32 instead. For example:

configure CFLAGS='-m32 -O2' CC=gcc-4.5

The difference seems to be that you can specify multiple -arch options to generate universal binaries, whereas -march only generates one at a time.

This error exists in many forms, regardless of the machine or build type. The solution, in general, is to change the PATH and CROSS_COMPILE variables to include the correct cross compiler.

The macports version of GCC doesn't support the -arch flag. As it turns out Apple's GCC is a wrapper around the real gcc that honors a few special flags before calling the real compiler. The -arch flag is one of these flags. It calls the appropriate compiler for each of the archs specified and then uses lipo to mash all of the object files back together into a "fat" object file.

I just spent a little bit of time getting this Apple GCC wrapper working with macports GCC. If you want the details you can find them here:

http://thecoderslife.blogspot.com/2015/07/building-with-gcc-46-and-xcode-4.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!