Alright, I got it to work. The trick was three things:

Change the emit to this: 
    
    
    # Required before including the stb_image.h header
    {.emit: """
    #define STB_IMAGE_IMPLEMENTATION
    #include "stb_image.h"
    """.}
    

Remove the "header," pragma and add a "noDecl" one: 
    
    
    # Internal Function
    proc stbi_load(filename: cstring; x, y, comp: var cint; req_comp: cint): 
cstring
      {.importc: "stbi_load", noDecl.}
    
    

Tell the compiler where to look for stb_image.h. In my case that file was right 
alongside stb_image.nim, so for me it was: 
    
    
    --cincludes:.
    

Reply via email to