首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从DLL C++导入函数的问题。LNK 2001

从DLL C++导入函数的问题。LNK 2001
EN

Stack Overflow用户
提问于 2013-07-17 17:59:46
回答 1查看 189关注 0票数 0

我有两个项目。一个创建DLL,另一个应该使用DLL中声明的函数,但我在实现这一点时遇到了问题。

在DLL项目中,我有以下声明:

代码语言:javascript
复制
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函数的项目中,我有以下内容:

代码语言:javascript
复制
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矩阵函数的代码如下:

代码语言:javascript
复制
    void xclass::ComputeWeightingMatrix(constellation &Constellation, char flagIntCont)
    {
        double sigma = 0.0;
        long error;

            ...
    }

当我尝试构建时,我得到了他的:

错误LNK2001:未解析外部符号"public: void __thiscall xclass::ComputeWeightingMatrix(class LNK2001 &,char)“char

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-17 22:11:43

在聊天中进行了一些讨论后,发现这个问题的解决方案有两个部分:

  1. 需要使用DLL类中的存根库。
  2. 需要使用class __declspec(dllexport) XClass来确保导出该类的功能。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17696751

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档