Brandon D.

asked • 09/08/19

What could cause the compiler to return the error " undefined reference to `Print' " ?

I've been working on this simple C project, trying to implement header, implementation, and makefiles. My professor provided the code for us to test, however whenever I use the "make hello3" command, the compiler gives me the error "undefined reference to `Print' " (Print is the name of the function trying to be implemented). Bellow are the files I've been working with.


Functions.h


#include <stdio.h>


void Print(char *str);


Functions.c


#include "Functions.h"


void Print(char *str)

{

printf("%s\n", str);

}


hello3.c


#include "Functions.h"


int main(int argc, char **argv)

{

char *myString="Hello, world!";

Print(myString);

return 0;

}


My Makefile


CC=gcc

OBJS=*.o

PROGS= hello3

INCS= -I.


hello3.o: hello3.c Functions.h

${CC} -c hello3.c


hello3: hello3.o Functions.o

${CC} hello3.o Functions.o -o hello3


Functions.o: Functions.c Functions.h

${CC} ${INCS} -c Functions.c


clean:

rm ${OBJS} ${PROGS}


2 Answers By Expert Tutors

By:

Patrick M. answered • 03/29/20

Tutor
New to Wyzant

Engineer with 10+ years of experience.

Keith B. answered • 09/08/19

Tutor
4.6 (22)

Software Engineer and Math Geek

Brandon D.

Ok I will check the tabs and yes there is a Functions.o file in my directory.
Report

09/08/19

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.