我在 OSX Lion 上有一个构建文件
VPATH = src include
CFLAGS ="-I include -std=gnu99"
hello: hello.o
gcc $^ -o $@
hello.o: hello.h hello.c
gcc $(CFLAGS) -c $< -o $@
但是当我尝试运行这个make文件时,我得到了以下错误
ld: warning: ignoring file hello.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
我尝试使用该标志-arch x86_64
,但仍然出现相同的错误。
运行arch
命令给出:i386
.
uname -a
告诉我:Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
我还尝试-march=x86-64
按照此答案文件中所述添加开关,该文件是为 i386 构建的,它不是在 Mac OSX 10.6 上为 iOS 4.2 编译 OpenCV2.2 时链接的体系结构(x86_64),但这对我不起作用。
命令行的输出是:
gcc -I include -std=gnu99 -m64 -c include/hello.h -o hello.o
gcc -I include -std=gnu99 -m64 hello.o -o hello
ld: warning: ignoring file hello.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [hello] Error 1