【问题标题】:Debugging a DLL that uses __stdcall and pragma linker调试使用 __stdcall 和 pragma 链接器的 DLL
【发布时间】:2013-04-18 16:49:19
【问题描述】:

我想调试一个 DLL。 这个 DLL 导出了一些函数和 void:

这是标题:

#ifdef CODEC_EXPORTS
#define CODEC_API __declspec(dllexport)
#else
#define CODEC_API __declspec(dllimport)
#endif

extern "C" CODEC_API int __stdcall SpxInit(void);
extern "C" CODEC_API int __stdcall SpxEncode(unsigned char* inBuf, unsigned char* outBuf, unsigned int inlen);
extern "C" CODEC_API int __stdcall SpxEncodeNormal(void);
extern "C" CODEC_API int __stdcall SpxDecode(unsigned char* DinBuf, float* DoutBuf,     unsigned int Dinlen);
extern "C" CODEC_API int __stdcall SpxFree(void);

#pragma comment(linker, "/export:SpxEncode=_SpxEncode@12")
#pragma comment(linker, "/export:SpxEncodeNormal=_SpxEncodeNormal@0")
#pragma comment(linker, "/export:SpxDecode=_SpxDecode@12")
#pragma comment(linker, "/export:SpxInit=_SpxInit@0")
#pragma comment(linker, "/export:SpxFree=_SpxFree@0")

我在我的解决方案中添加了一个新项目,并简单地添加了以下 cpp 文件:

#include "stdafx.h"
#include "codec.h"

int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}

现在在尝试其他任何事情之前,我只是想编译新项目,但 VC2010 告诉我

"error LNK2001" Unresolved external symbol "_SpxDecode@12"
"error LNK2001" Unresolved external symbol "_SpxEncode@12"

等等……

所以我想我错过了什么,但我没有看到。

【问题讨论】:

    标签: c++ windows linker pragma


    【解决方案1】:

    您需要将reference 添加到您的 dll 项目中
    项目属性->通用属性->参考

    【讨论】:

      猜你喜欢
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 2010-09-11
      • 2013-08-13
      • 1970-01-01
      • 2012-01-15
      • 2011-05-19
      • 1970-01-01
      相关资源
      最近更新 更多