Hi all -- I'm using Nim 0.20.2 on Ubuntu 16.04 and reading this page:
[https://nim-lang.org/docs/backends.html](https://nim-lang.org/docs/backends.html)
I'm looking at the code to statically generate a library.
$ nim c --app:staticLib --noMain --header fib.nim
$ gcc -o m -Inimcache -Ipath/to/nim/lib libfib.nim.a maths.c
Run
The first command does not produce a file called libfib.nim.a as shown, which
was my first problem.
It does produce the header file fib.h in the nimcache and a binary ar output
fib in the current directory, so I tried renaming fib to libfib.nim.a and
proceeding. Then I got a linker error:
$ gcc -o m -I$HOME/.cache/nim/fib_d/
-I$HOME/.choosenim/toolchains/nim-0.20.2/lib/ libfib.nim.a maths.c
/tmp/ccm37fDt.o: In function `main':
maths.c:(.text+0x9): undefined reference to `NimMain'
maths.c:(.text+0x1c): undefined reference to `fib'
collect2: error: ld returned 1 exit status
Run
Both fib.nim and maths.c are copy/pasted from the example.
Anyone have more experience doing these type of builds? Thanks!