When compiling example code, compiler cannot resolve references to the exported definitions
/usr/bin/ld: /home/rhenvar/.cache/nim/test_d/@mtest.nim.c.o: in function `ngx_link_func_init_cycle':
@mtest.nim.c:(.text+0xad): undefined reference to `ngx_link_func_cyc_log_info'
/usr/bin/ld: /home/rhenvar/.cache/nim/test_d/@mtest.nim.c.o: in function `ngx_link_func_exit_cycle':
@mtest.nim.c:(.text+0x1ad): undefined reference to `ngx_link_func_cyc_log_warn'
/usr/bin/ld: /home/rhenvar/.cache/nim/test_d/@mtest.nim.c.o: in function `hello':
@mtest.nim.c:(.text+0x2b8): undefined reference to `ngx_link_func_log_info'
/usr/bin/ld: @mtest.nim.c:(.text+0x2d6): undefined reference to `ngx_link_func_get_query_param'
/usr/bin/ld: @mtest.nim.c:(.text+0x343): undefined reference to `ngx_link_func_write_resp'
/usr/bin/ld: /home/rhenvar/.cache/nim/test_d/@mtest.nim.c.o: in function `post':
@mtest.nim.c:(.text+0x495): undefined reference to `ngx_link_func_write_resp'
collect2: error: ld returned 1 exit status
Error: execution of an external program failed: 'gcc -o /home/rhenvar/ParadigmInteractive/dataAPIServer/src/pkg/test /home/rhenvar/.cache/nim/test_d/stdlib_system.nim.c.o /home/rhenvar/.cache/nim/test_d/stdlib_strutils.nim.c.o /home/rhenvar/.cache/nim/test_d/@mtest.nim.c.o -lm -ldl -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
shell returned 1
import ngxcmod, strutils
proc init(ctx: ContextCycle) {.init.} =
ctx.cyc_log(INFO, "hello from Nim")
proc exit(ctx: ContextCycle) {.exit.} =
ctx.cyc_log(WARN, "goodbye, from Nim w/ <3")
proc hello(ctx: Context) {.exportc.} =
ctx.log(INFO, "Calling back and log from hello")
let
name = ctx.getQueryParam("name")
message = "hello $#, greeting from Nim" % name
ctx.response(200, "200 OK", CONTENT_TYPE_PLAINTEXT, message)
proc post(ctx: Context) {.exportc.} =
ctx.response(200, "200 OK", CONTENT_TYPE_PLAINTEXT, ctx.getBodyAsStr())
[rhenvar@manjaro pkg]$ nim --version
Nim Compiler Version 1.0.4 [Linux: amd64]
Compiled at 2019-11-27
Copyright (c) 2006-2019 by Andreas Rumpf
active boot switches: -d:release -d:nativeStackTrace