필자는 Paul Carter 박사의 pcasm-book.pdf (http://www.drpaulcarter.com/pcasm/) - NASL을 사용하여 어셈블리를 배우려고합니다. Mac OS X Snow Leopard에 있습니다.OSX에서 gcc가 사용하는 파일 형식은 무엇입니까?
나는 ASM 샘플을 이전 컴파일 된 C 샘플을 연결하기 위해 노력하고있어 :
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
을 내가 ASM을 컴파일 마하 - 오 형식을 사용하고 있습니다 샘플, 내가 가지고 오류 없음
nasm -f macho **first.asm**
nasm -f macho asm_io.asm
난 단지의 gcc -c driver.c에있는 모든 오브젝트 파일을 링크 LD를 사용하여, 리터를 사용하려고하면 d는 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을 사용하기위한 올바른 형식은 무엇입니까?
감사합니다. Daniel Koch
감사합니다. Gcc는 기본적으로 x86_64를 사용하지만 NASM의 "macho"형식은 i386입니다. –
@DanielKoch 당신이 마침내 당신을 위해 일한 것을 게시 할 수 있습니까? 나는 아직도 컴파일 오류를 얻는다. – gideon
@ gideon 새로운 질문을 게시하거나 시도중인 명령과보고있는 오류에 대한 링크를 포함시켜야합니다. 또는 내 답변에 대해 이해하지 못했던 내용을 설명하여 개선 할 수 있습니다. –