【问题标题】:error LNK2019: unresolved external symbol __imp__debugf referenced in function "int __cdecl fld_new错误 LNK2019:函数“int __cdecl fld_new”中引用了未解析的外部符号 __imp__debugf
【发布时间】:2013-04-12 13:09:21
【问题描述】:

我正在将我的项目从 VS 6 升级到 VS 2010,在发布模式下构建时,我遇到了以下错误。

 1>Creating library .\Release\JfFrpF32.lib and object .\Release\JfFrpF32.exp> 
 1>FLD_.obj : error LNK2019: unresolved external symbol __imp__debugf referenced in  function "int __cdecl fld_new(char *,unsigned char,unsigned char,short,char,char,unsigned char,short,char,double,double,short,char *,char,short,short)" (?fld_new@@YAHPADEEFDDEFDNNF0DFF@Z)
 1>Release/JfFrpF32.dll : fatal error LNK1120: 1 unresolved externals
 1>
 1>Build FAILED.

请帮助我..提前谢谢..

【问题讨论】:

  • 你能从FLD_.cpp粘贴fld_new吗

标签: visual-c++


【解决方案1】:

导致 LNK2019 的常见问题包括:

  • 符号的声明包含拼写错误,例如, 它与符号的定义不同。

  • 使用了函数,但参数的类型或数量没有 匹配函数定义。

  • 调用约定(__cdecl、__stdcall 或 __fastcall)在 函数声明和函数定义的使用。

  • 符号定义位于编译为 C 程序的文件中,并且 符号在没有 extern "C" 修饰符的 C++ 文件中声明。在 这种情况下,修改声明。

欲了解更多信息See Here

【讨论】:

  • 链接失效了。
【解决方案2】:

在我的例子中,即使我使用了extern "C",我也得到了未解决的符号错误。
hpp 是

extern "C"
{
class A
{
public:
    void hi();
};
A* a;
DECLDIR int Connect();
}//extern

而cpp是

#include "DatabasePlugin.hpp"// Include our header, must come after #define DLL_EXPORT


extern "C" // Get rid of name mangling
{   
    DECLDIR int Connect()
    {
        a = new A();
        a->hi();
        return 0;
    }//Connect
}//extern

问题是我没有为hi() 函数创建一个实现。添加它解决了这个问题。像这样:

extern "C" // Get rid of name mangling
{   
    void A::hi() {}

    DECLDIR int Connect()
    {
        a = new A();
        a->hi();
        return 0;
    }//Connect
}//extern

必须在Connect() 之前声明Hi() 也可能很重要。

【讨论】:

    猜你喜欢
    • 2014-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多