Hello,

I'm trying to make a [Wren](http://wren.io/) wrapper for Nim, but I have 
trouble understanding Nim's FFI. So far I've got a folder structure like this:
    
    
    src/
    - wren.nim
    - wren/
      - incl/
        - wren.h
        - wrapper.nim
      - vm/(...)
    
    Run

The `src/wren/vm` folder's contents can be found here: 
[https://github.com/wren-lang/wren/tree/master/src/vm](https://github.com/wren-lang/wren/tree/master/src/vm)

I tried using the `importc` macro in `wrapper.nim` like this: 
    
    
    # tell the C compiler to look for the wren header
    # unfortunately this must be done as Nim doesn't copy the .h filed from the 
header pragma to its compile cache
    from os import splitPath
    {.passC: "-I" & currentSourcePath.splitPath.head.}
    
    const h = "wren.h"
    
    type
      WrenConfiguration* {.importc, header: h.} = object
    
    proc wrenInitConfiguration*(cfg: ptr WrenConfiguration) {.importc: 
"wrenInitConfiguration", nodecl.}
    
    
    Run

However, when I try and test if the `wrenInitConfiguration` proc works, I get 
this error:
    
    
    /usr/bin/ld: /home/[username]/.cache/nim/test1_d/wren_test1.c.o: in 
function `NimMainModule':
    wren_test1.c:(.text+0x95e): undefined reference to `wrenInitConfiguration'
    collect2: error: ld returned 1 exit status
    
    
    Run

What am I doing wrong, and how can I make a wrapper properly?

Reply via email to