Skip to content

Trouble loading a Dll with the following error #10

@MaheshE99ME25

Description

@MaheshE99ME25

Hi,

I was trying to Embed a well known dll for Process fluid properties library in my program with memlib:

http://coolprop.org/
dll here: https://sourceforge.net/projects/coolprop/files/CoolProp/6.6.0/shared_library/Windows/64bit/

The program compiles, but when executed i encountered the following errors:
C:...\ ..\coolpropex.nim(12) coolpropex
C:....\coolpropex.nim(1057) Propssi1
C:......\memlib.nim(927) memlookup
C:......\memlib.nim(647) loadLib
C:......\memlib.nim(629) checkedLoadLib
C:......\memlib.nim(601) loadLib
C:......\memlib.nim(472) initialize
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

The code is as below:

import strutils
import memlib
const CoolDll = staticReadDll("CoolProp.dll")
let CoolLib = checkedLoadlib(CoolDll)

The above code executes as expected if i try with sqlite dll.

However, the function can be accessed if accessed with dynlib or link pragma by dynamic linking, i.e., the following works:
import strutils
import memlib
proc Propssi*(Output: cstring; Name1: cstring; Prop1: cdouble; Name2: cstring; Prop2: cdouble; Ref: cstring): cdouble {.cdecl, importc: "PropsSI".}
{.link : "CoolProp.dll".}
let temperature: cdouble = 300.0 # Example temperature in Kelvin
let pressure: cdouble = 1.0 # Example pressure in MPa
let fluid : cstring = "R134a" # Example FLUID NAME
echo $Propssi("H", "T", temperature, "P", pressure, fluid) # Example RESULT

Thank you for taking time to respond and for great set of Windows libraries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions