Cannot Compile Assembly on my Mac!
$ gcc -m32 hw3.c -o hw3
Undefined symbols:
"i", referenced from:
_main in ccuNMbgT.o
_main in ccuNMbgT.o
(maybe you meant: _i, _main , cstring=hey, supposed to supply an in开发者_开发技巧teger argument , cstring=after multiply, value is %d
, _i$non_lazy_ptr , _printf , _environ , _atoi , _exit )
ld: symbol(s) not found
collect2: ld returned 1 exit status
I'm doing assembly with some C. I'm trying to compile an example that worked on Ubuntu compiled using gcc
, but its not working on my Mac terminal.
It told you the problem and gave you the solution ("maybe you meant: ..."). Whether C symbols get underscores prepended to them in assembler is one of those things that is highly platform-dependent; on OS X they do, so when referring to a variable named "i" in C you must call it "_i" in assembler.
精彩评论