I'm trying to include a function like this in C++ and I can't understand why it's not working. I have 3 files.
test.cc
int test() {
std::cout << "This is a test" << std::endl;
}
test.h
int test();
main.cc
#include "test.h"
int main() {
test();
return 0;
}
This is the error I got and the command I used.
c++ main.cc -o main
Undefined symbols for architecture x86_64:
"test()", referenced from:
_main in main-12ba52.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)