I got unresolved external symbol error when trying to use a function from external dll! Here is the code from exported dll:
//MathFunc.h
#pragma once
template <class T>
class MyMathFuncs
{
public:
    T Add(T a, T b);
};
extern "C" {
    MYAPI MyMathFuncs<int>* createInst(){
        return new MyMathFuncs<int>;
    }
}
//MathFunc.cpp
#include "MathFuncsDll.h"
#include <stdexcept>
using namespace std;
template <class T>
T MyMathFuncs<T>::Add(T a, T b)
{
    return a + b;
}
After compiling this project, I got .dll and .lib files. After that, I created a new project and added .dll file to output directory and .lib file to linker->Input->Additional dependencies. Here is code in the new project:
//main.cpp
#include <iostream>
#include "MathFuncsDll.h"
using namespace std;
int main(){
    MyMathFuncs<int> * pObj = createInst();
    cout << pObj->Add(1, 1) << endl;
    cin.get();
    return 0;
}
However, when I compile it causes an error:
Error   1   error LNK2001: unresolved external symbol "public: int __thiscall       MyMathFuncs<int>::Add(int,int)" (?Add@?$MyMathFuncs@H@@QAEHHH@Z)    N:\Play around Code\DllApplication\DllApplication\main.obj
Is it because I have imported the dll wrongly or what? I have checked all the project's settings in the new project which included additional includes and additional dependencies(for .lib).
 
    