I'm trying to access a DLL on Windows using the following code:
import os
let dll = joinPath(getAppDir(), "DebenuPDFLibrary64DLL1311.dll")
type
DPL* = object
id: int32
proc createLibrary(): int32 {.cdecl, dynlib: dll,
importc: "DPLCreateLibrary".}
proc releaseLibrary(id: int32): void {.cdecl, dynlib: dll,
importc: "DPLReleaseLibrary".}
proc newDPL*(): DPL =
result.id = createLibrary()
proc close*(dpl: DPL): void =
if dpl.id != 0:
releaseLibrary(dpl.id)
if isMainModule:
var dpl = newDPL()
defer: dpl.close()
Here's what happens when I try to compile and run it:
R:\pdfpage>nim c -r debenu.nim
Hint: used config file 'c:\bin\nim\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: debenu [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: algorithm [Processing]
Hint: times [Processing]
Hint: winlean [Processing]
Hint: dynlib [Processing]
CC: debenu
CC: stdlib_system
CC: stdlib_os
CC: stdlib_winlean
Hint: [Link]
Hint: operation successful (20168 lines compiled; 1.422 sec total;
34.004MiB; Debug Build)
[SuccessX]
Hint: R:\pdfpage\debenu.exe [Exec]
No stack traceback available
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: 'R:\pdfpage\debenu.exe '
I'm pretty sure the DLL was compiled using a Microsoft compiler, while Nim, of
course, is using gcc.
Can anyone advise?