[racket] Windows FFI Problem

From: Ben Goetter (goetter at mazama.net)
Date: Fri Jan 16 14:40:38 EST 2015

On 1/16/2015 11:00 AM, Lehi Toskin wrote:
> Good news is it's giving me a new error! Yay! "%1 is not a valid Win32 
> application.; errno=193"

This is /the/ classical 32-versus-64-bit mismatch error.  Most likely, 
once of the DLLs that your DLL in turn depends on is loading in the 
wrong flavor.  Bitness is the most likely suspect, but you could also 
conceivably have a version compiled for a different target architecture.

To decipher this and future error codes, look them up in winerror.h in 
your Windows SDK.  Then go grepping through msdn.microsoft.com with the 
name of the constant.  This one is ERROR_BAD_EXE_FORMAT.

You probably should take Racket out of the loop here.  Write a four-line 
C program that explicitly tries to load your DLL. Something like

#include <windows.h>
HANDLE h = LoadLibraryA("mydll.dll");
if (NULL == h) printf("ERROR %lu\n", GetLastError());
else { FreeLibrary(h); printf("Great success\n"); }

Compile that fragment in the same bitness of your Racket installation on 
Windows, and use it to ensure that your DLL itself can resolve all its 
dependencies.  Once your DLL can pass this test, feed it to Racket.

Ben


Posted on the users mailing list.