[racket] Windows FFI Problem

From: Lehi Toskin (lehi at tosk.in)
Date: Fri Jan 16 14:00:35 EST 2015

On Fri, 16 Jan 2015 10:19:38 -0700, Matthew Flatt wrote:

> Along the lines of these suggestions, you could try using an absolute
> path to the DLL.
> 
> If an absolute path works, then it's probably an issue of the search
> path for DLLs, and using `define-runtime-path` might be the best
> approach.
> 
> If an absolute path doesn't work, then it might be a mismatch between
> Racket and the DLL (32-bit versus 64-bit builds) or a missing DLL, as
> others have suggested.
> 
> At Fri, 16 Jan 2015 11:01:31 -0500, Michael Wilber wrote:
>> Does this work if you place the .DLL in the same directory as the
>> Racket executable?
>> 
>> What if it's placed in your System32 folder?
>> 
>> If you need to put the library in a nonstandard path (I think putting
>> the .dll in the same folder as the .rkt script is nonstandard), try
>> registering the DLL. See
>> http://stackoverflow.com/questions/4897685/how-do-i-register-a-dll-
file-on-wind
>> ows-7-64-bit
>> 
>> Lehi Toskin <lehi at tosk.in> writes:
>> > On Thu, 15 Jan 2015 18:55:41 -0700, Matthew Flatt wrote:
>> >
>> >> At Thu, 15 Jan 2015 22:10:35 +0000 (UTC), Lehi Toskin wrote:
>> >>> I am attempting to use this C library I've written with the Racket
>> >>> FFI,
>> >>> but (ffi-lib "mylib") reports "The specified module could not be
>> >>> found.;
>> >>> errno=126". This only happens on Windows. On Linux the library gets
>> >>> loaded properly and I can use it fine. What could be the problem?
>> >>
>> >> Can you say more about where "mylib.dll" is located in your Windows
>> >> installation --- and maybe also where it's located on Linux, for
>> >> comparison?
>> >>
>> >>
>> > I actually have the library in the same directory as the script for
>> > both platforms. I've tried "mylib", "mylib.dll" and even permutations
>> > of "path/
>> > to/lib/directory/mylib".
>> > ____________________
>> >   Racket Users list: http://lists.racket-lang.org/users
>> ____________________
>>   Racket Users list: http://lists.racket-lang.org/users
> ____________________
>   Racket Users list: http://lists.racket-lang.org/users

I have checked and double checked the 32/64-bitness of both the library 
and the Racket installation and they are definitely the same... It 
appears that specific error I am getting is caused by the fact that 
"mylib.dll" depends on other DLL's to compile that it wasn't locating 
when the racket script was being run and when I moved it to where the 
other DLL's were, it stopped giving me that error.

Good news is it's giving me a new error! Yay!
"%1 is not a valid Win32 application.; errno=193"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20150116/b15de651/attachment.sig>

Posted on the users mailing list.