-1

I have a header file cerealmanager.h and a main file called cerealmanager.cpp and a file called project2.cpp, which just has catch 2 tests.

Whenever I run my code with the makefile it says that all of my functions are undefined (undefined reference CerealManager::(functionname).

How do I solve this issue?

makefile

CPP_FLAGS = -std=c++11 -Wall -Wextra -Werror

# uncomment for Linux/Mac OS X
#RM = rm -f

# uncomment for Windows (make sure MinGW/MSYS are installed!)
RM = del

project2.exe: project2.cpp cerealmanager.o
  g++ $(CPP_FLAGS) project2.cpp cerealmanager.o -o project2.exe

cerealmanager.o: cerealmanager.h cerealmanager.cpp
  g++ $(CPP_FLAGS) -c cerealmanager.cpp -o cerealmanager.o

clean:
  $(RM) *.o

cleanall: clean
  $(RM) *.exe
  • 2
    The rules applicable here to this type of question require that you reduce the problem to a simple compact case which still demonstrates the issue and post the entirety of the code and compiler error output. Likely in the course of doing that, you'll identify the issue yourself. – Chris Stratton Mar 16 '19 at 20:38
  • 2
    Hey! Welcome to Stackoverflow :) Is it possible for you to provide a [minimal, complete, and verifiable example](https://stackoverflow.com/help/mcve) of your problem? – JMAA Mar 16 '19 at 20:40

1 Answers1

0

As you said, it’s maybe due to the Makefile. But I think this is not the case.

You can read more regarding “undefined reference to” here

Hope this will help you.

Ido Segal
  • 430
  • 2
  • 7
  • 20