mingw 컴파일러와 코드 블록 IDE를 사용하고 있습니다. 나는이 기능을 사용하여 심지어 __declspec(dllexport)
을 사용하여도 내 dll이 모든 기능을 수출하는 방법을 이해하지 못하는 문제에 직면하고있다.내 dll이 내 동의없이 모든 기능을 내보내고 있습니다!
main.h
:
#ifndef __MAIN_H__
#define __MAIN_H__
#include windows.h
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void SomeFunction(const LPCSTR sometext);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__
main.cpp
: 여기에 두 개의 샘플 파일, main.h
및 main.cpp
있는이 예에서
#include "main.h"
void SomeFunction(const LPCSTR sometext)
{
MessageBoxA(0, sometext, "DLL fxn Message", MB_OK | MB_ICONINFORMATION);
}
bool flag = false;
extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
flag = true;
return TRUE; // succesful
}
이
SomeFunction
내보낼와 나는 동적에서 호출 할 수 있어요 비록 내가 프로토 타입 화하지는 않았지만 외부 적으로 애플리케이션이다.
void __declspec(dllexport) SomeFunction(const LPSTR sometext);
뿐만 아니라 전역 변수 flag
조차도 자동 생성 .def 파일로 내보내집니다.
여기 무슨 일입니까? 제가 기술적 인 실수를 저지르고 있다면 저를 도와주십시오.
가능한 중복 [? 모든 기호를 수출하지는 MinGW 링커를 말할 방법] (http://stackoverflow.com/questions/2810118/how- : 이것은 GCC의 인간이 페이지에서 무시 될 수 있습니다 to-tell-the-mingw-linker-not-to-export-all-symbols) – laalto