【问题标题】:linking error with one function only LNK 2019仅与一项功能链接错误 LNK 2019
【发布时间】:2014-09-15 13:17:03
【问题描述】:

我在 dll 中有以下类

header

class __declspec(dllexport) MyClass
{
public:
bool fun1(const CString& csFilename, int& nFileID );
bool fun2(int nFileID, int nImageNum, int nStartIndex);
};

cpp

bool MyClass::fun1(const CString& csFilename, int& nFileID )
{
}

bool Myclass::fun2(int nFileID, int nImageNum, int nStartIndex)
{
}

main

void main()
{
MyClass *p = new MyClass;
p->fun1(...); //if I comment this code compiles and builds
p->fun2(...); //this is ok
}

我收到错误 LNK2019: unresolved external symbol "public: bool __thiscall... 只为 fun1 不为 fun2 甚至都在同一个班为什么? 提前致谢。

【问题讨论】:

  • 发布实际的函数调用和实际的错误文本。
  • 很抱歉无法提供实际代码仍然感谢提示我会检查这个方向。
  • 不能提供实际代码是什么意思?您需要做的就是显示您如何调用fun1,并粘贴编译器输出。我非常怀疑它们是否包含重要的商业机密。
  • 感谢您的提示,它有效问题是 CString 我用 std::string 替换了它,一旦我获得更多技术细节,我会回答。

标签: c++ dll mfc


【解决方案1】:

我不确定这里出了什么问题,因为在我用 std 字符串替换 CString 后它可以工作,但我无法在另一个小示例中重现相同的错误。 @admin 我认为这个帖子应该被删除,因为我无法复制它。

【讨论】:

    猜你喜欢
    • 2014-05-13
    • 1970-01-01
    • 2013-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-19
    相关资源
    最近更新 更多