title: From bootsector to C++ kernel
body: <p>I decided to write a simple asm bootloader and a c++ kernel. I read a lot of tutorials, but I cant compile an assembly file seems like this:</p>
  
  <pre><code>[BITS 32]
  [global start]
  [extern _k_main]
  start:
     call _k_main
     cli
     hlt
  </code></pre>
  
  <p>(I would like to call th k_main function from c file)</p>
  
  <p>Compile/assemble/linking errors:</p>
  
  <pre><code>nasm -f bin -o kernelstart.asm -o kernelstart.bin:
  error: bin file cannot contain external references
  </code></pre>
  
  <p>okay, then i tried create a .o file:</p>
  
  <pre><code>nasm -f aout -o kernelstart.asm -o kernelstart.o  (That's right)
  ld -i -e _main -Ttext 0x1000 kernel.o kernelstart.o main.o
  error: File format not recognized
  </code></pre>
  
  <p>Someone give me plz a working example or say how to compile. :/
  (I'm browsing the tutorials and helps 2 days ago but cannot find a right answer)</p>