Hi,
With below code I'm getting a strange error with no stack trace. Any
suggestions?
app.nim
import dynlib
type
Value* = ref object
P* = proc(): Value {.nimcall.}
when isMainModule:
var lib = loadLib("libext.dylib")
var test: P = cast[P](lib.symAddr("test"))
echo test() != nil
Run
ext.nim
import ./app
proc test*(): Value {.dynlib exportc.} =
Value()
Run
$ nim -v
Nim Compiler Version 1.4.6 [MacOSX: amd64]
Compiled at 2021-05-22
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
$ nim c --app:lib --outdir:. ext.nim
$ nim c -r app.nim
CC: stdlib_system.nim
CC: app.nim
Hint: /Users/gcao/proj/gene/tmp/bin/app [Exec]
true
No stack traceback available
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed:
'/Users/gcao/proj/gene/tmp/bin/app '
Run