C++ Fundamentals / Organazing functions in files issue

Hello folks,

I am running into a bit of an issue with the tutorial.

This is the error I am getting.

c++ /home/sitrixs/Clion/ClionProjects/HelloWorld/main.cpp -o main
/usr/bin/ld: /tmp/ccmfqRb9.o: in function main': main.cpp:(.text+0x30): undefined reference to greet(std::__cxx11::basic_string<char, std::char_traits, std::allocator >)’
collect2: error: ld returned 1 exit status

Here are is the code of my files.

Cmake:

cmake_minimum_required(VERSION 4.0)
project(HelloWorld)

set(CMAKE_CXX_STANDARD 20)

add_executable(HelloWorld main.cpp utils/greet.cpp)

main.cpp:

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

using namespace std;


int main() {
    greet("Guy");

    return 0;
}

greet.hpp:

#ifndef UTILS_GREET
#define UTILS_GREET
#include <string>

void greet(std::string name);

#endif

greet.cpp:

#include <iostream>

using namespace std;

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

The only way I managed to get this working, is adding #include greet.cpp into the main.cpp or to the greet.hpp , this allows the code to compile, if i try to follow the step by step in the video, i get an error mentioned above.

I am running this in Clion, on Bazzite (Linux Distro) so not sure if it has something to do with the error.

Looking forward for your help.

Thanks.