This post may not apply to 64 bit systems for all I know, but it works on 32 bit Windows...
I tried GENDEF, and it failed to produce a DEF file. Having already solved this problem for my own purposes in beginning to write DLL's, I suggest using Tiny_impdef.exe from TCC, which works. (TCC = Tiny C Compiler, by Fabrice Bellard, and later, Grishka.) What's more, unlike DLLTOOL (and possibly GENDEF), it works whether GCC used -s to strip the output DLL or not!
Use DLLTOOL to generate the *.a library file from the DEF, if using GCC. TCC will do the entire build of DLL and EXE, using just two command lines. I have a set of commands that will allow either the DLL, or the EXE, to be built by GCC, or TCC, with all four possible combinations working.
Batch file below, for plundering at will... I'm sure it can be bettered, but at least it works cleanly as is.
@ECHO OFF
REM This system seems to work regardless of which compiler makes the DLL or the EXE. Try to simplify for GCC.
REM TCC COMMANDS. Creates 3 files, DLL and DEF, then EXE.
REM E:\CODING\TCC\TCC.EXE -shared E:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.c -oE:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.dll
REM E:\CODING\TCC\TCC.EXE E:\CODING\TCC\EXAMPLES\Test_DLL\Test_EXE.c E:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.def -oE:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.exe
REM GCC COMMANDS. WARNING! Still needs TCC's Tiny_Impdef.exe!
E:\CODING\GCC\BIN\GCC.EXE -s -shared -IE:\CODING\GCC\INCLUDE -mwindows E:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.c -oE:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.dll
E:\CODING\TCC\"Tiny_Impdef.exe" E:\CODING\TCC\EXAMPLES\TEST_DLL\TEST_DLL.DLL > NUL
E:\CODING\GCC\MINGW32\BIN\DLLTOOL.EXE -d E:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.def -lE:\CODING\TCC\EXAMPLES\Test_DLL\libTest_DLL.a
E:\CODING\GCC\BIN\GCC.EXE -s -IE:\CODING\GCC\INCLUDE -mwindows E:\CODING\TCC\EXAMPLES\Test_DLL\Test_EXE.c E:\CODING\TCC\EXAMPLES\Test_DLL\libTest_DLL.a -oE:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.exe
START E:\CODING\TCC\EXAMPLES\Test_DLL\Test_DLL.exe
For completeness, here's the C code for the test DLL:
#include <windows.h>
#define DLL_EXPORT __declspec(dllexport)
DLL_EXPORT void ZoodleWurdle(){
MessageBox (0, "Wurdle", "Zoodle", MB_ICONINFORMATION);
}
DLL_EXPORT void MangleWurzel(){
MessageBox (0, "Mangled", "Wurzels", MB_ICONINFORMATION);
}
Sorry about the Gummidgisms, but I had to start somewhere, and I never liked foo and bar, or hello and world... Here's the EXE:
#include <windows.h>
void ZoodleWurdle();
void MangleWurzel();
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
ZoodleWurdle(); MangleWurzel();
return 0;
}