13
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/cppapplication_1
mkdir -p build/Debug/GNU-MacOSX
rm -f build/Debug/GNU-MacOSX/main.o.d
g++ -arch i386   -c -g -MMD -MP -MF build/Debug/GNU-MacOSX/main.o.d -o build/Debug/GNU-MacOSX/main.o main.cpp
cc1plus: error: unrecognized command line option "-arch"
make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 311ms)

simpatico$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin10/4.5.1/lto-wrapper
Target: x86_64-apple-darwin10
Configured with: ../gcc-4.5.1/configure --prefix=/opt/local --build=x86_64-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,fortran,java --libdir=/opt/local/lib/gcc45 --includedir=/opt/local/include/gcc45 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.5 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.5 --with-gxx-include-dir=/opt/local/include/gcc45/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --enable-stage1-checking --disable-multilib --enable-fully-dynamic-string
Thread model: posix
gcc version 4.5.1 (GCC) 

这个简单的文件:

#include <stdlib.h>

int main(int argc, char** argv) {

    return (EXIT_SUCCESS);
}
4

4 回答 4

12

-arch选项是 Apple 对gcc. 您需要使用gccApple 的开发者工具提供的Xcode.

于 2010-12-08T19:07:55.990 回答
1

此错误以多种形式存在,无论机器或构建类型如何。通常,解决方案是更改 PATH 和 CROSS_COMPILE 变量以包含正确的交叉编译器。

于 2013-05-15T20:34:51.587 回答
1

-arch选项仅在 Apple 提供的gcc. 更改CFLAGS(可能通过您的环境、您的 makefile 或您的配置选项设置)使其使用-march-m32代替。例如:

配置CFLAGS='-m32 -O2' CC=gcc-4.5

不同之处似乎在于您可以指定多个-arch选项来生成通用二进制文件,而-march一次只能生成一个。

于 2011-11-18T15:18:49.677 回答
0

GCC 的 macports 版本不支持 -arch 标志。事实证明,Apple 的 GCC 是真正 gcc 的包装器,它在调用真正的编译器之前尊重一些特殊标志。-arch 标志是这些标志之一。它为每个指定的拱门调用适当的编译器,然后使用 lipo 将所有目标文件重新组合成一个“胖”目标文件。

我只是花了一点时间让这个 Apple GCC 包装器与 macports GCC 一起工作。如果您想了解详细信息,可以在这里找到它们:

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

于 2012-03-02T16:52:38.303 回答