Mac OS X Snow Leopard で、ポール カーター博士の pcasm-book.pdf ( http://www.drpaulcarter.com/pcasm/ ) である NASM を使用してアセンブリを学習しようとしています。
以前にコンパイルした C サンプルを asm サンプルにリンクしようとしています。
gcc first.o driver.c asm_io.o -o first
しかし、それはそれを返しています:
driver.c:3: warning: ‘cdecl’ attribute ignored
ld: warning: in first.o, **file is not of required architecture**
ld: warning: in asm_io.o, file is not of required architecture
Undefined symbols:
  "_asm_main", referenced from:
      _main in ccjLqYJn.o
ld: symbol(s) not found
Mach-o 形式を使用して asm サンプルをコンパイルしていますが、エラーは発生しませんでした。
nasm -f macho **first.asm**
nasm -f macho asm_io.asm
driver.c で gcc -c のみを使用し、ld を使用してすべてのオブジェクト ファイルをリンクしようとすると、ld は driver.o 形式をリンクしていないように見えます。
ld -o first asm_io.o first.o driver.o
戻り値:
ld: warning: in driver.o, file is not of required architecture
Undefined symbols:
  "_putchar", referenced from:
      print_char in asm_io.o
      print_nl in asm_io.o
  "_printf", referenced from:
      print_int in asm_io.o
      print_string in asm_io.o
      push_of in asm_io.o
      sub_dump_stack in asm_io.o
      stack_line_loop in asm_io.o
      sub_dump_mem in asm_io.o
      mem_outer_loop in asm_io.o
      mem_hex_loop in asm_io.o
      sub_dump_math in asm_io.o
      tag_loop in asm_io.o
      print_real in asm_io.o
      invalid_st in asm_io.o
  "_scanf", referenced from:
      read_int in asm_io.o
  "_getchar", referenced from:
      read_char in asm_io.o
ld: symbol(s) not found for inferred architecture i386
どうしたの?OS X で gcc と NASM を使用するための正しい形式は何ですか?
ありがとうございました。ダニエル・コッホ