title: How to compile using nasm on MacOSX
body: <p>I am trying to compile and link my first program on Assembler.
  I try to compile the following code:</p>
  
  <pre><code>; %include "stud_io.inc"    
  global _main     
  
  section .text
  _main: 
      xor eax, eax
  again:
      ; PRINT "Hello"
      ; PUTCHAR 10
      inc eax     
      cmp eax, 5
      jl again
  </code></pre>
  
  <p>Below the console command for compiling and linking a program:</p>
  
  <pre><code>-bash-3.2$ nasm -f macho main.asm -o main.o  &amp;&amp; ld -e _main -macosx_version_min 10.8 -arch x86_64 main.o
  </code></pre>
  
  <p>But the result is:</p>
  
  <pre><code>ld: warning: ignoring file main.o, file was built for i386 which is not the architecture being linked (x86_64): main.o
  Undefined symbols for architecture x86_64:
    "_main", referenced from:
       -u command line option
  ld: symbol(s) not found for architecture x86_64
  </code></pre>
  
  <p>I think its necessary to compile the main.asm file for x86_64..
  How to compile programs for my system properly? </p>