maybe this is too naive a toy example, but it works: `clib.c` int sum(int a,int b){return a+b;} Run
`nimlib.nim` {.compile:"clib.c".} #proc sum(a,b:int32):int32{.importc.} ## as @auxym says; if it's not static, it's exported ## even if you dont use it in the nim file when compileOption("app","lib"): {.push,dynlib.} proc mul(a,b:int32):int32{.exportc.} = a * b Run `nimlib.h` int sum(int a, int b); int mul(int a, int b); Run `main.c` #include "nimlib.h" #define i(x) *a[i] - '0' int main(int _, char** a){ return mul(sum(i(1),i(2)),sum(i(3),i(4))); } Run building and running: $ nim c -d:release --app:staticLib --noMain nimlib.nim $ gcc main.c -L. -l:libnimlib.a --OR-- $ nim c -d:release --app:lib --noMain nimlib.nim $gcc main.c -L. -Wl,-rpath,. -lnimlib $ ./a.out 1 2 3 4; echo $? 21 Run