Hi,<br><br>just a wild guess: .def files for C++ projects have to list the mangled names, so if you want the export name to be just &quot;testfunc&quot;, it should be declared as &#39;extern &quot;C&quot;&#39;.<br><br>Petr<br>
<br><div class="gmail_quote">On Thu, Sep 13, 2012 at 8:17 AM, Ali Hamdi <span dir="ltr">&lt;<a href="mailto:alha02@gmail.com" target="_blank">alha02@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello everybody,<br>
<br>
I am trying to create a DLL by using a .DEF file and targeting the<br>
MinGW gcc-compiler. In my CMakeLists.txt I have this:<br>
<br>
add_library(MyDll SHARED<br>
                MyDll.cpp<br>
                dllmain.cpp<br>
                stdafx.cpp<br>
                MyDll.def).<br>
<br>
I have the following sources:<br>
<br>
MyDll.def:<br>
<br>
LIBRARY libMyDll<br>
EXPORTS testfunc<br>
<br>
stdafx.cpp:<br>
<br>
#include &quot;stdafx.h&quot;<br>
<br>
stdafx.h:<br>
<br>
#define WIN32_LEAN_AND_MEAN<br>
#include &lt;windows.h&gt;<br>
<br>
dllmain.cpp:<br>
<br>
#include &quot;stdafx.h&quot;<br>
<br>
BOOL APIENTRY DllMain( HMODULE hModule,<br>
                       DWORD  ul_reason_for_call,<br>
                       LPVOID lpReserved<br>
                                         )<br>
{<br>
        switch (ul_reason_for_call)<br>
        {<br>
        case DLL_PROCESS_ATTACH:<br>
        case DLL_THREAD_ATTACH:<br>
        case DLL_THREAD_DETACH:<br>
        case DLL_PROCESS_DETACH:<br>
                break;<br>
        }<br>
        return TRUE;<br>
}<br>
<br>
and finally<br>
<br>
MyDll.cpp:<br>
<br>
#include &quot;stdafx.h&quot;<br>
<br>
__declspec(dllexport) int __stdcall testfunc(int x )<br>
{<br>
        return 1;<br>
}<br>
<br>
<br>
If I do a regular cmake to create Visual Studio files, everything<br>
compiles and links just fine (within VS Express 2010). But if I use<br>
the CMAKE GUI and explicitly target MinGW, and then use make in the<br>
cmd-prompt then I get the following error:<br>
<br>
Creating library file: libMyDll.dll.a<br>
Cannot export testfunc: symbol not defined<br>
<br>
<br>
Any idea of what I am doing wrong here? I would really appreciate some help.<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>