【发布时间】:2011-08-02 20:21:17
【问题描述】:
我正在使用面向 .Net 4.0 的 Visual Studio 2010
我正在使用托管 C++ 包装器处理非托管 C++ dll。我正在使用_declspec(dllexport) 导出非托管.dll 下面是非托管dll的头文件:
class DllExport KeyManager
{
public:
KeyManager(const char *pszKeyFileName, int thisProduct);
~KeyManager();
...
然后我在这里从托管包装器调用非托管 dll:
#include "stdafx.h"
#include "KeyModCLR.h"
#using <mscorlib.dll>
#include <msclr/marshal.h>
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace msclr::interop;
MCKeyManager::MCKeyManager(String ^fileName, int thisProduct)
{
pszFileName = (char*)Marshal::StringToHGlobalAnsi(fileName).ToPointer();
m_pC = new KeyManager(pszFileName, thisProduct);
}
当项目以 Win32 为目标时,这一切都很好,但是当我按照here 的描述将目标平台更改为 x64 时,我收到以下错误:
Error 17 error LNK2019: unresolved external symbol "public: __cdecl
KeyManager::KeyManager (char const *,int)" (??0KeyManager@@$$FQEAA@PEBDH@Z) referenced in
function "public: __clrcall MCKeyManager::MCKeyManager(class System::String ^,int)" (?? 0MCKeyManager@@$$FQE$AAM@PE$AAVString@System@@H@Z)
我对 C++ 不是很熟悉,因为我没有编写这段代码,所以我不知道我是否遗漏了一些明显的东西。我读过 64 位和 32 位的导入函数的装饰是不同的,但我不确定这对我有什么影响。
我一整天都在寻找答案,但结果很短,所以任何建议或建议都将不胜感激。
提前致谢
【问题讨论】:
标签: c++ 64-bit wrapper managed