So I have a function pointer defined in my main class like this:
namespace Lab
{
namespace Math
{
namespace Port
{
void main()
{
typedef void(*objfunptr)(int, int, const double[], double[], double[], int);
objfunptr objfun= ObjectiveFunctions::ExampleObjFun;
// Till Here it compiles fine but after calling the function we have error
objfun(m, n, xPtr, fPtr, fjacPtr, td);
}
}
}
}
I Get the Following Error:
Error 16 error LNK2001: unresolved external symbol "public: static void __cdecl Lab::Math::Port::ObjectiveFunctions::ExampleObjFun ...
My ObjectiveFunctions source and header are defined like this:
Header:
namespace Lab
{
namespace Math
{
namespace Port
{
public class ObjectiveFunctions
{
public:
static void ObjectiveFunctions::ExampleObjFun(int m, int n, const double x[], double f[], double fjac[], int fjacp);
};
}
}
}
Source:
namespace Lab
{
namespace Math
{
namespace Port
{
static void ExampleObjFun(int m, int n, const double x[], double f[], double fjac[], int fjacp){
//Do whatever;
}
}
}
}
Note that this whole thing work if I write the function inside the same file,but when I add the namespaces and seperate the Objectivefunctions into another Class I Get this Peoblem.
I Have looked alot in internet and they say you have to declare and define the functionsso the compiler won't get crazy. But I did declare and Define! I don't know what would be the problem.