1
클래스가없는 C++ 동적 라이브러리를 만들려고합니다. <string.h
>을 포함 시켜서 strlen을 직접 호출하는 것과 비슷한 방식으로 작업하고 싶습니다.클래스 이름없이 C++ 라이브러리 만들기
컴파일 할 클래스를 만들 수 있지만 내 라이브러리와 올바르게 연결되지 않습니다. 여기
내가 지금 일하고 있어요 테스트 라이브러리입니다 :#ifndef _DLL_H_
#define _DLL_H_
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved);
extern "C" __declspec(dllexport) int testMethod(int a);
#endif
CPP가
#include "dll.h"
int testMethod(int num)
{
std::cout << "test message" << std::endl;
return 1;
}
BOOL APIENTRY DllMain (HINSTANCE hInst, // Library instance handle. ,
DWORD reason, // Reason this function is being called. ,
LPVOID reserved) // Not used. )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
// Returns TRUE on success, FALSE on failure
return TRUE;
}
마지막으로, 여기에 내가 DLL을 테스트하기 위해 사용하고 클래스의
헤더한다 lib mingw 출력에 연결하라는 메시지가 표시됩니다.
#include <iostream>
#include "../Dll/dll.h"
using namespace std;
int main(int argc, char *argv[])
{
testMethod(5);
}
나는 이것은 DLL에 연결하는 응용 프로그램에 같이 DllImport 할 필요가
"내 라이브러리에 올바르게 연결되지 않습니다."어떤 종류의 오류 메시지 또는 문제가 있습니까? – aschepler