I am trying to make static library for solving probability and stats. I am getting LNK2019 unresolved external symbol error when running my code. I think the program isnt detecting the definitions of function from the .cpp file and i dont get the issue here. Also i have given the main file directions for the library so no issue there. I am new in using headers and templates so kindly help. The error occurs when the program calls the constructor for the object:
> LNK2019 unresolved external symbol "public: __thiscall ProbnStatslib::means<float>::means<float>(void)"(??0?$means@M@ProbnStatslib@@QAE@XZ) referenced in function_main
Header file:
// .h file
#ifndef PROBNSTATSLIB_H
#define PROBNSTATSLIB_H
#include<iostream>
#include<vector>
namespace ProbnStatslib
{
template<typename any>
class means
{
private:
std::vector<any> xi_mean;
int N;
public:
means();
void initializer(int size);
void CalcMean();
};
}
#endif
The .cpp
// .cpp
#include<iostream>
#include"ProbnStatslib.h"
#include<vector>
using namespace std;
namespace ProbnStatslib
{
template<typename any>
means<any>::means()
{
cout << "object constructed" << endl;
cout << "Enter number of ouccrances:" << endl;
cin >> this->N;
initializer(this->N);
}
template<typename any>
void means<any>::initializer(int size)
{
cout << "Enter event values or Xi of size:"<< size << endl;
/*for (any value : xi_mean)
{
cin >> this->xi_mean;
}*/
}
template<typename any>
void means<any>::CalcMean() {
cout << "Calculating" << endl;
}
}
The main file:
#include <iostream>
#include <vector>
#include "ProbnStatslib.h"
using namespace std;
using namespace ProbnStatslib;
int main()
{
means<float> myobj;
return 0;
}