[CMake] Creating a DLL using .DEF file on MinGW
Ali Hamdi
alha02 at gmail.com
Thu Sep 13 02:17:35 EDT 2012
Hello everybody,
I am trying to create a DLL by using a .DEF file and targeting the
MinGW gcc-compiler. In my CMakeLists.txt I have this:
add_library(MyDll SHARED
MyDll.cpp
dllmain.cpp
stdafx.cpp
MyDll.def).
I have the following sources:
MyDll.def:
LIBRARY libMyDll
EXPORTS testfunc
stdafx.cpp:
#include "stdafx.h"
stdafx.h:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
dllmain.cpp:
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
and finally
MyDll.cpp:
#include "stdafx.h"
__declspec(dllexport) int __stdcall testfunc(int x )
{
return 1;
}
If I do a regular cmake to create Visual Studio files, everything
compiles and links just fine (within VS Express 2010). But if I use
the CMAKE GUI and explicitly target MinGW, and then use make in the
cmd-prompt then I get the following error:
Creating library file: libMyDll.dll.a
Cannot export testfunc: symbol not defined
Any idea of what I am doing wrong here? I would really appreciate some help.
More information about the CMake
mailing list