我有两个项目。一个创建DLL,另一个应该使用DLL中声明的函数,但我在实现这一点时遇到了问题。
在DLL项目中,我有以下声明:
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;
};在必须使用DLL函数的项目中,我有以下内容:
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;
}ComputeWeighting矩阵函数的代码如下:
void xclass::ComputeWeightingMatrix(constellation &Constellation, char flagIntCont)
{
double sigma = 0.0;
long error;
...
}当我尝试构建时,我得到了他的:
错误LNK2001:未解析外部符号"public: void __thiscall xclass::ComputeWeightingMatrix(class LNK2001 &,char)“char
发布于 2013-07-17 22:11:43
在聊天中进行了一些讨论后,发现这个问题的解决方案有两个部分:
class __declspec(dllexport) XClass来确保导出该类的功能。https://stackoverflow.com/questions/17696751
复制相似问题