Compilation error in UFO Project - Header File Issues

I’m trying to complete the UFO project in the C++ courseline. I’m finding that nothing I add to the header/function file compiles correctly, not even the display_misses() function that comes pre-written with the workspace. Any function I try to call from the file produces the same error:

/tmp/ccp5dsi9.o: In function main': ufo.cpp:(.text+0x5): undefined reference to greet()’
collect2: error: ld returned 1 exit status

When I put the function in the body of ufo.cpp, it executes normally, but not if I move it to ufo_functions.cpp. I really can’t figure out what’s going wrong here.

Hi, can you share what your headers are like? It’s hard to tell from just the error message what is wrong here.

Thanks for your help.

The main ufo.cpp file has the following header:

#include "ufo_functions.hpp"

ufo_functions.hpp has
void greet();

And ufo_functions.cpp has

void greet() {

  std::cout << "=============\n";
  std::cout << "UFO: The Game\n";
  std::cout << "=============\n";
  std::cout << "Instructions: save your friend from alien abduction by guessing the letters in the codeword.\n";


I can’t figure out why this isn’t working.

Hi. How are you linking hpp and cpp? There should be some sort of include there.

It might just be quicker to provide all the files to debug this faster.

I’m linking ufo.cpp to ufo_functions.hpp via #include "ufo_functions.hpp" in ufo.cpp. Is there something I need to do to link ufo_functions.hpp to ufo_functions.cpp?

Never mind, I figured out what I was doing wrong - I need to compile ufo.cpp and ufo_functions.cpp simultaneously.