I have a very strange problem with the GCC 5.4.0 linker. I have these files:
spline.h,
utils.h/cpp,
main.cpp
spline.h is a header-only utility class for fitting points to splines.
1) I create a library with utils.cpp and CMake:
add_library(utils_lib utils.cpp)
utils.h is #includeing spline.h.
2) I create my binary from main.cpp:
add_executable(hello_world main.cpp)
target_link_libraries(hello_world utils_lib)
3) Inside utils.cpp, I have this function:
tk::spline fitSpline(const std::vector<double>& x,
                     const std::vector<double>& y)
{
    tk::spline output;
    output.set_points(x,y);
    return output;
}
So, if I try to use this function inside main.cpp:
auto my_spline = fitSpline(x,y);
Then I get this linker error:
undefined reference to `fitSpline(std::vector<double, std::allocator<double> > const&, std::vector<double, std::allocator<double> > const&)'
However if I change the return value of fitSpline to double for example:
double fitSpline(const std::vector<double>& x,
                 const std::vector<double>& y)
{
    tk::spline output;
    output.set_points(x,y);
    return 0.0;
}
Then I don't get the linker error anymore! It compiles just fine. I really don't understand what the problem is, any hints?
Thanks!
 
     
    