调试使用__stdcall和pragma链接器的DLL

时间:2013-04-18 16:49:20

标签: c++ windows linker pragma

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

这是标题:

#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"

等...

所以我想我错过了什么,但我看不出来。

1 个答案:

答案 0 :(得分:0)

您需要将reference添加到您的dll项目中 项目属性 - >公共属性 - >参考文献

相关问题