Re: How to embed a header file into a .nim file

2018-02-11 Thread DTxplorer
I solved this by using "\--passL" instead of "\--passC "

Re: How to embed a header file into a .nim file

2018-02-09 Thread DTxplorer
I tried to import a C file, that includes GLFW, in "test.nim", like this but I fail. nim c --passC: '`pkg-config glfw3 --static --cflags --libs`' test.nim before that the .o file is created succesfully, like this. gcc -Wall -c test.c -I. All GLFW s

Re: How to embed a header file into a .nim file

2018-02-09 Thread cheatfate
@mratsim, so maybe its a nimble problem to setup compilation behavior properly, so you can use just header:"" without any hacks with {.passC.}.

Re: How to embed a header file into a .nim file

2018-02-09 Thread guibar
This workaround worked for me, but it is still hacky. Assuming the header file is in the same directory than the nim file: from os import splitPath {.passC:"-I" & currentSourcePath().splitPath.head .} Not tested, but the following could work. const myHeader =

Re: How to embed a header file into a .nim file

2018-02-09 Thread mratsim
It doesn't work for headers distributed through nimble. For some users the path will be `{.header:"/home/cheatfate/.nimble/pkgs/foopkg-0.1.0/headers/fooheaders.h".}` and others will have `{.header:"/Users/mratsim/.nimble/pkgs/foopkg-0.2.0/headers/fooheaders.h".}` ` There is probably a way thro

Re: How to embed a header file into a .nim file

2018-02-09 Thread cheatfate
Actually **header** pragma will be converted to **#include "header"**, so C compiler is looking it in current directory and directories specified in **-I** argument. So you can easily **{.passC:"-I/some/directory/you/want".}** and it will start looking for your headers not only in 'nimcache' dir

Re: How to embed a header file into a .nim file

2018-02-08 Thread mratsim
Resurrecting this thread as I stumbled upon the exact same issue. The library from def_pri_pub (stb_image) and the library I'm wrapping (ttmath) are header-only so we can't link to a library. I've noticed that `{.importc: "someProc", header: "path/to/header".}` is either absolute or relative to

Re: How to embed a header file into a .nim file

2016-12-22 Thread Araq
Sorry for this late response but usually your `nim` file doesn't have to depend on a C header file at all. `importc` the identifiers and either use `.dynlib` or some `{.link: "lib.a".}` command to link against the library.

Re: How to embed a header file into a .nim file

2016-12-17 Thread def_pri_pub
I went with yglukhov's solution (since it seemed to be the simplest to use), but It's really what I wanted to avoid doing.

Re: How to embed a header file into a .nim file

2016-12-17 Thread LeuGim
Headers can be included via `{.emit: """#include "../some_header.h.}`, or when using symbols from it: `proc f: int {.importc: "some_c_func", header: "../some_header.h".}`. The path with "../" is for the case when the header is in the folder with Nim code and "nimcache" folder too.

Re: How to embed a header file into a .nim file

2016-12-17 Thread Arrrrrrrrr
I think you could rename your header file to c and then inside header_lib.nim add: {.compile: "header_lib.c".} [http://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compile-pragma](http://forum.nim-lang.org///nim-lang.org/docs/manual.html#implementation-specifi

Re: How to embed a header file into a .nim file

2016-12-17 Thread yglukhov
How about this? [https://github.com/yglukhov/nimx/blob/master/nimx/load_image_impl.nim](https://github.com/yglukhov/nimx/blob/master/nimx/load_image_impl.nim)

How to embed a header file into a .nim file

2016-12-17 Thread def_pri_pub
So I'm working on wrapper for a library (stb_image) that is contained in a single header file. Right now if I want to get things to compile and work, I have to tell the nim compiler where that header file is located. For example, if my project structure is like this: src/ - ma