C++, undefined reference to the function

I encountered the following error when I tried to compile the program according to the “Functions/8-Organizing Functions in Files” episode:

undefined reference to greet(std::__cxx11::basic_string<char, std::char_traits, std::allocator >)'`

I am using C++ 20, and GCC 10.3.0.

The program includes the following files:

main.cpp

#include <iostream>
#include "utils/greet.h"

using namespace std;

int main() {
    string name = "Mike";
    greet(name);
    return 0;
    }

utils/greet.cpp

#include <iostream>

using namespace std;

void greet(string& name){
    cout << "Hello " << name;
}

utils/greet.h

#ifndef HELLOWORLD_GREET_H
#define HELLOWORLD_GREET_H

#include <string>

void greet(std::string name);

#endif //HELLOWORLD_GREET_H

How did you do your compilation? I think you need to explicitly compile / link all of the relevant files in order to make this work. So something like this:

g++ *.cpp utils/*.cpp -o output
./output