Im pretty new to multi-file compilation on c++, and I'm trying to understand it by testing.
But in the example below I'm getting an error undefined reference to `func()'
and I can't understand why.
Thanks in advance!
Main.cpp
#include <iostream>
#include "file1.h"
int main() {
func();
return 0;
}
File1.h
#ifndef UNTITLED1_FILE1_H
#define UNTITLED1_FILE1_H
#include <iostream>
void func();
#endif //UNTITLED1_FILE1_H
File1.cpp
#include "file1.h"
void func() {
std::cout << "Test" << std::endl;
}
CMAKELIST
cmake_minimum_required(VERSION 3.17)
project(untitled1)
set(CMAKE_CXX_STANDARD 14)
add_executable(untitled1 main.cpp file1.h)