从DLL C++导入函数时出现问题.LNK 2001
Issue importing functions from DLL C++. LNK 2001
我有两个项目。一个创建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 Matrix函数的代码:
void xclass::ComputeWeightingMatrix(constellation &Constellation, char flagIntCont)
{
double sigma = 0.0;
long error;
...
}
当我尝试构建时,我得到了他的:
错误LNK2001:未解析的外部符号"public:void __thiscall xclass::ComputeWeightingMatrix(class constellation&,char)"(?ComputeWeightingMatrix@xclass@@$$FQAEXAAVconstellation@@D@Z)
在Chat中进行了一些讨论后,发现这个问题的解决方案有两部分:
- 需要使用DLL类中的存根库
- 需要使用
class __declspec(dllexport) XClass
来确保导出类中的功能
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 编译包含字符串的代码时遇到问题
- Project Euler问题4的错误解决方案
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 一个关于在C++中重载布尔运算符的问题
- 首要问题的答案让值班员搞错了
- setlocale的C++土耳其字符串问题
- LNK 2005链接器出现msvcrt.lib(MSVCR90.dll)问题
- 从DLL C++导入函数时出现问题.LNK 2001
- 从C++dll导入函数时出现问题,错误LNK 2019
- LNK 2019未解决的外部问题