title: file was built for unsupported file format which is not the architecture being linked (x86_64)
body: <p>I have a build file on OSX Lion</p>
  
  <pre><code>VPATH = src include
  CFLAGS ="-I include -std=gnu99"
  
  hello: hello.o
      gcc $^ -o $@
  
  hello.o: hello.h hello.c
      gcc $(CFLAGS) -c $&lt; -o $@
  </code></pre>
  
  <p>But when I try and run this make file I get the following error</p>
  
  <pre><code>    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
  </code></pre>
  
  <p>I have tried using the flag <code>-arch x86_64</code> but still get the same error.</p>
  
  <p>Running the <code>arch</code> command gives: <code>i386</code>.</p>
  
  <p><code>uname -a</code> tells me: <code>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</code></p>
  
  <p>I've also tried to add the switch <code>-march=x86-64</code> as described in this answer <a href="https://stackoverflow.com/questions/5220435/file-was-built-for-i386-which-is-not-the-architecture-being-linked-x86-64-whil">file was built for i386 which is not the architecture being linked (x86_64) while compiling OpenCV2.2 for iOS 4.2 on Mac OSX 10.6</a> but that hasn't worked for me.</p>
  
  <p>The output from the command line is:</p>
  
  <pre><code>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
  </code></pre>