我有一個.lib,它具有我想要製作成DLL的函數。無法導出DLL中的函數
在項目屬性中,我做了2件事情, 1.在C/C++ - >常規 - >其他目錄中:爲.h文件添加路徑。 2.在鏈接器>常規 - >額外Dependies:添加的路徑的的.lib文件
然後我由h文件
#ifndef _DFUWRAPPER_H_
#define _DFUWRAPPER_H_
#include <windows.h>
#include "DFUEngine.h"
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) void helloworld(void);
__declspec(dllexport) void InitDLL();
#ifdef __cplusplus
}
#endif
#endif
並把cpp文件
#include "stdafx.h"
#include "stdio.h"
#include "DFUWrapper.h"
#ifdef _MANAGED
#pragma managed(push, off)
#endif
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
#ifdef _MANAGED
#pragma managed(pop)
#endif
void helloworld(void)
{
printf("hello world DFU");
}
DFUEngine* PyDFUEngine()
{
return new DFUEngine();
}
void delDFUEngine(DFUEngine *DFUe)
{
DFUe->~DFUEngine();
}
void PyInitDLL(DFUEngine *DFUe)
{
return DFUe->InitDLL();
}
我用helloword函數做了測試。我可以在DLL中看到這個函數,但不能看到InitDLL函數。 我怎樣才能解決這個問題?請幫助
Visual Studio中,大概。什麼版本?你的意思是什麼你不能「看」功能?顯示一些數據/錯誤/輸出。 –
正在使用VS2005。我正在檢查依賴沃克。我可以看到halloworld()函數,但不是InitDLL() – user3484496
在你的.c文件中它是'PyInitDll'。在你的.h它是'InitDll' – agbinfo