Hello guys!
I have these 3 files:
Code:
//main.cpp
#include "lib.h"
int main ()
{
foo();
return 0;
}
Code:
//lib.h
void foo();
Code:
//lib.cpp
#include "lib.h"
#include <iostream>
void foo()
{
std::cout<<"it works!";
}
and in Dev-C++ I get an error that says: "undefined reference to foo".
I know it's very simple, am I missing something in the code? Should I compile/link them manually from console?
Note: I read that this is the recommended way to write/include a libray, but I still don't understand how lib.cpp gets to be used in main.cpp as main.cpp only has a reference of lib.h, and lib.h doesn't say anything about the source file (lib.c).
Thanks!