C++ 从DLL C+导入函数+;。LNK 2001
我有两个项目。一个创建DLL,另一个应该使用DLL中声明的函数,但我在实现这一点时遇到了问题 在DLL项目中,我有以下声明:C++ 从DLL C+导入函数+;。LNK 2001,c++,dll,dllimport,dllexport,lnk2001,C++,Dll,Dllimport,Dllexport,Lnk2001,我有两个项目。一个创建DLL,另一个应该使用DLL中声明的函数,但我在实现这一点时遇到了问题 在DLL项目中,我有以下声明: using namespace XClass; extern "C" __declspec(dllexport) int Compute(XClass::XClassInput input, XClassOutput &XClassOutput); extern "C" __declspec(dllexport) int Init( string config
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 u thiscall xclass::ComputeWeightingMatrix(类星座和字符)”(?ComputeWeightingMatrix@xclass@@$$FQAEXAAV星座@@D@Z)在Chat中经过一些讨论后,这个问题的解决方案分为两部分:
class\uu declspec(dllexport)XClass
以确保导出类中的功能那么您的
xclass::ComputeWeightingMatrix
的代码在哪里?它与函数的内容相关吗?或者只是它的声明?它的定义在哪里?您是如何构建代码的?]我编辑了这篇文章,展示了声明和定义。至于建筑,我添加了DLL项目作为参考,在项目中调用DLL。这就是您所指的吗?那么,您是否链接到xclass DLL的.lib文件?