I'm quite new to C++ programming and it seams that I have fundamental problems in understanding how the compiling and linking works. Here is my Minimum example: I have thre files a.hpp, a.cpp and b.cpp.
a.hpp:
namespace A {
template<typename T>
double helpA(T t1,T t2);
}
a.cpp:
#include "a.hpp"
namespace A {
template<typename T>
double helpA(T t1, T t2){
return(t1 +t2);
}
}
b.cpp (main)
#include <iostream>
#include "a.hpp"
int main (int argc, char *argv[]){
double t = A::helpA(1.0,2.3);
std::cout << t << "\n";
}
When I now try to compile the Thing by calling
g++ b.cpp a.cpp
I get the following error:
b.cpp:(.text+0x24): undefined reference to `double A::helpA<double>(double, double)'
collect2: error: ld returned 1 exit status
Every help is appriciated