Reputation: 1959
i've got a gcc version 2.95.2 19991024 (release) toolchain and now i need to use an Assembly function that is in a file positioned in the same folder of the makefile.
I've tried tons of ways to put that file in my toolchain, with no luck.
Basically i declare that in ASM:
.globl util_MyFunc
util_MyFunc:
...
And in the main void of C file:
extern void util_MyFunc();
int main(void) {
util_MyFunc();
...
When i compile i got the error related to not recognized:
/cygdrive/c/MyDev/tmp/main.o(.text+0x8bc): undefined reference to `util_MyFunc'
make: *** [test.o] Error 1
Thanks!
EDIT:
i've tried to use following to generate the ".o" file from the asm file
C:\MyDev>gcc -c test.asm -o test.o
It results:
gcc: utils.asm: linker input file unused since linking not done
or:
C:\MyDev>gcc test.asm -o test.o
but...:
ld: cannot open crt0.o: No such file or directory
Upvotes: 0
Views: 356
Reputation: 58762
The canonical extension for assembly files that gcc expects is .s
. You should use that (or assemble using as
directly). Also possibly put the -o test.o
before the input file name. Finally, you will need libc development files if you want to use libc. Otherwise use -nostdlib
switch.
You should try: gcc -o test main.c utils.s
Upvotes: 2