“undefined reference” error in a very very simple c++ program
I have a simple program, which I copied exactly from the example in http://www.learncpp.com/cpp-tutorial/19-header-files/ because I'm learning how to make c++ programs with multiple files. The program compiles but when building, the following error appears: /tmp/ccm92rdR.o: In function main: main.cpp:(.text+0x1a): undefined reference to `add(int, int)' collect2: ld returned 1 exit status Here's the code: main.cpp #include <iostream> #include "add.h" // this brings in the declaration for add() int main() { using namespace std; cout << "The sum of 3 and 4 is " << add(3, 4) << endl; return 0; }