I have a 3 files in one directory, a file source.cpp, a file main.cpp, and a file header.h. Their contents is as follows:
//source.cpp
#include "header.h"
void out(){
std::cout << "It's working properly.";
}
//header.h
#ifndef HEADER_H
#define HEADER_H
void out();
#endif
//main.cpp
#include "header.h"
int main(){
out();
return 0;
}
When I compile main.cpp, I receive the error message
/tmp/ccSxCGDZ.o: In function `main':
main.cpp:(.text+0x5): undefined reference to `out()'
collect2: error: ld returned 1 exit status
I am compiling with g++. I have not compiled anything else or done any extra steps, so there may be something that I am just forgetting. I have never tried to use a header before, so please forgive me if this is a simple question.