digitalmars.D.learn - How to build dll?
- Jack (5/24) Dec 02 2020 called from:
- Jack (4/32) Dec 02 2020 for same reason, the dll build with ldc2 works fine, compiled
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (3/25) Dec 02 2020 Just out of curiosity, are you sure that you compile both your c
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (2/29) Dec 03 2020 May be this will help: https://github.com/vitalfadeev/dlang-dll
- frame (2/3) Dec 03 2020 As always... have you tired dmd -m32mscoff ?
D code:import core.sys.windows.dll; mixin SimpleDllMain; version(Windows) extern(C) export int foo() { return 42; }compiled with:dmd -ofmydll.dll -shared -m32 dll.dcalled from:typedef int (__cdecl *MYPROC)(void); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR szCmdLine, int CmdShow) { HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; // Get a handle to the DLL module. hinstLib = LoadLibrary(TEXT("mydll.dll"));but hinstLib is NULL and GetLastError() = 193:ERROR_BAD_EXE_FORMAT 193 (0xC1) %1 is not a valid Win32 application.What am I missing?
Dec 02 2020
On Wednesday, 2 December 2020 at 19:42:37 UTC, Jack wrote:D code:for same reason, the dll build with ldc2 works fine, compiled with:import core.sys.windows.dll; mixin SimpleDllMain; version(Windows) extern(C) export int foo() { return 42; }compiled with:dmd -ofmydll.dll -shared -m32 dll.dcalled from:typedef int (__cdecl *MYPROC)(void); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR szCmdLine, int CmdShow) { HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; // Get a handle to the DLL module. hinstLib = LoadLibrary(TEXT("mydll.dll"));but hinstLib is NULL and GetLastError() = 193:ERROR_BAD_EXE_FORMAT 193 (0xC1) %1 is not a valid Win32 application.What am I missing?ldc2 -shared dll.d -ofmydll.dllwhat am I missing?
Dec 02 2020
On Wednesday, 2 December 2020 at 20:08:29 UTC, Jack wrote:On Wednesday, 2 December 2020 at 19:42:37 UTC, Jack wrote:Just out of curiosity, are you sure that you compile both your c and d codes for the same arc?D code:for same reason, the dll build with ldc2 works fine, compiled with:[...]compiled with:[...]called from:[...]but hinstLib is NULL and GetLastError() = 193:[...]What am I missing?ldc2 -shared dll.d -ofmydll.dllwhat am I missing?
Dec 02 2020
On Wednesday, 2 December 2020 at 19:42:37 UTC, Jack wrote:D code:May be this will help: https://github.com/vitalfadeev/dlang-dllimport core.sys.windows.dll; mixin SimpleDllMain; version(Windows) extern(C) export int foo() { return 42; }compiled with:dmd -ofmydll.dll -shared -m32 dll.dcalled from:typedef int (__cdecl *MYPROC)(void); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR szCmdLine, int CmdShow) { HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; // Get a handle to the DLL module. hinstLib = LoadLibrary(TEXT("mydll.dll"));but hinstLib is NULL and GetLastError() = 193:ERROR_BAD_EXE_FORMAT 193 (0xC1) %1 is not a valid Win32 application.What am I missing?
Dec 03 2020
On Wednesday, 2 December 2020 at 19:42:37 UTC, Jack wrote:What am I missing?As always... have you tired dmd -m32mscoff ?
Dec 03 2020