le fichier a été construit pour non pris en charge le format de fichier qui n'est pas l'architecture d'être lié (x86_64)

J'ai un fichier de build sur 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 $@

Mais quand j'essaie de l'exécuter ce fichier j'obtiens l'erreur suivante

    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

J'ai essayé d'utiliser le drapeau -arch x86_64 mais toujours la même erreur.

De l'exécution de l' arch commande donne: i386.

uname -a me dit: 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

J'ai aussi essayé d'ajouter le commutateur -march=x86-64 comme décrit dans cette réponse le fichier a été construit pour les architectures i386 qui n'est pas l'architecture d'être lié (x86_64) lors de la compilation OpenCV2.2 pour iOS 4.2 sur Mac OSX 10.6 mais cela n'a pas fonctionné pour moi.

La sortie de la ligne de commande est:

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

OriginalL'auteur | 2012-04-16