Using a very simple source and header file setup (main.cpp, callbacks.h and callbacks.cpp) I get an error message saying: Undefined reference to "error_callback(int, char const*)"
. It seems some have run into the same problem, but not with quite as simple circumstances, which is what has really thrown me off.
Here are the files:
main.cpp
#include <stdio.h>
#include "callbacks.h"
int main(void){
char er[] = "Error.";
error_callback(1, er);
return 0;
}
callbacks.h:
#ifndef CALLBACKS_H
#define CALLBACKS_H
void error_callback(int error, const char* description);
#endif // CALLBACKS_H
and finally callbacks.cpp:
#include <stdio.h>
#include "callbacks.h"
void error_callback(int error, const char* description){
fprintf(stderr, "Error: %s\n", description);
}
I cannot possibly imagine a simpler header file setup - yet something's gone wrong. I'm 99.9% sure I've managed the header and source files correctly.
EDIT
It seems it was an issue with the IDE Code Blocks. Source files will show in the directories even if they are not properly linked in the project. Manually adding every file again resolved the issue.