DLL import failing

Q&A's, tips, howto's
Locked
dexterlagan
Posts: 4
Joined: Sun Jul 15, 2018 1:54 pm

DLL import failing

Post by dexterlagan »

Hi folks,

First post ever. I'm attempting to compile the Genann neural network library into a DLL for import into newLISP.

https://github.com/codeplea/genann

I updated the C source and its header to comply with either STDCALL or CDECL conventions (tried both with no success). I tried several methods to output a DLL out of the C source, which all work fine except when importing in newLISP. The methods I tried are described here :

https://www.transmissionzero.co.uk/comp ... ith-mingw/

I checked the exports using Dependency Walker, and all functions are exported correctly (at least when using CDECL, somehow the STDCALL one still showed up as a C export.
No matter what I do newLISP returns the usual import error when attempting to import the DLL :

ERR: problem loading library in function import : "genann.dll"

My import line :

(import "genann.dll" "genann_init") (when stdcall)
or
(import "genann.dll" "genann_init" "cdecl")

I tried using the absolute path (with slashes) to the DLL, as well as both calling conventions, to no avail.
I tried compiling the DLL both with gcc straight to DLL (-shared etc.) and through mingw's dllwrapper, to the same result. The DLL file I'm getting seems legit, and I have no problem importing it from C.

Has anybody encountered this problem?

Thanks in advance!

Dexter

dexterlagan
Posts: 4
Joined: Sun Jul 15, 2018 1:54 pm

Re: DLL import failing

Post by dexterlagan »

I figured it out. Lutz pointed out I was using the 32 bits version of MingW, with the 64 bits version of newLISP. All I had to do is :

1) install MingW64
2) compile the genann source with:
gcc -m64 genann.c -shared -o genann.dll

Cheers,

Dexter

Locked