rhazzak
rhazzak

Reputation: 3

'undefined reference to' in main.o

I'm a new user here so I'll be grateful for your patience and all advices. When I call make, I get an error:

gcc main.o func.o -m32 -o prog
main.o:main.c:(.text+0x56): undefined reference to '_fractal"
collect2: ld returned 1 exit status

Here's my makefile:

CC = gcc
OBJ = main.o func.o
BIN = prog
CFLAGS = -m32
$BIN: $(OBJ)
    $(CC) $(OBJ) $(CFLAGS) -o $(BIN)

main.o: main.c
    $(CC) $(CFLAGS) -c main.c -o main.o

func.o: func.s 
    nasm -f elf func.s

I have main.c and func.s files. Anybody could explain me what's wrong and how to fix it?

Upvotes: 0

Views: 847

Answers (1)

user5499791
user5499791

Reputation:

C uses underscore prefix for function calls.

Haven't you used fractal instead of _fractal in your external assembly module?

Upvotes: 1

Related Questions