Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble loading a Dll with the following error #10

Open
MaheshE99ME25 opened this issue Aug 12, 2024 · 0 comments
Open

Trouble loading a Dll with the following error #10

MaheshE99ME25 opened this issue Aug 12, 2024 · 0 comments

Comments

@MaheshE99ME25
Copy link

MaheshE99ME25 commented Aug 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant