Reputation: 993
I have two projects. One creates a DLL and the other should use functions declared in the DLL, but I have problems implementing this.
In the DLL project I have these declarations:
using namespace XClass;
extern "C" __declspec(dllexport) int Compute(XClass::XClassInput input, XClassOutput &XClassOutput);
extern "C" __declspec(dllexport) int Init( string configFileName);
class xclass
{
public:
xclass(void);
xclass(constellation &Constellation, XClass::XClassConfig &XClassConfig);
void ComputeWeightingMatrix(constellation &xclass_constellation, char flagIntCont);
void ComputeGMatrix(constellation &Constellation, XClass::XClassInput &input);
private:
int _numberOfSystemStates;
};
In the project that has to use the DLL functions I have this:
int _tmain(int argc, _TCHAR* argv[])
{
XClass::XClassConfig xClassConfig;
XClassOutput xClassOutput;
XClass::XClassInput input;
init(input, xClassOutput );
constellation* class_constellation = new constellation(input, xClassConfig);
xclass* algorithm = new xclass(*xclass_constellation, xClassConfig);
algorithm->ComputeWeightingMatrix(*xclass_constellation, 'i');
return 0;
}
The code for the ComputeWeighting Matrix function:
void xclass::ComputeWeightingMatrix(constellation &Constellation, char flagIntCont)
{
double sigma = 0.0;
long error;
...
}
When I try to build I get his:
error LNK2001: unresolved external symbol "public: void __thiscall xclass::ComputeWeightingMatrix(class constellation &,char)" (?ComputeWeightingMatrix@xclass@@$$FQAEXAAVconstellation@@D@Z)
Upvotes: 0
Views: 198
Reputation: 129314
After some discussion in Chat, it turns out there are two parts to the solution of this problem:
class __declspec(dllexport) XClass
to ensure the functionality from the class is exported.Upvotes: 1