nimble build -d:glfwStaticLib --verbose src/tutorial_glfw3/minimal.nim tutorial_glfw3/minimal
Then compilation works fine:
Info: Package cache path /home/hmf/.nimble/pkgcache
Info: Nimble data file "/home/hmf/.nimble/nimbledata2.json" has been loaded.
Info: Dependency on nim@>= 0.17.2 already satisfied
Info: Dependency on nim@>= 2.0.8 already satisfied
Info: Dependency on nim@>= 2.2.4 already satisfied
Info: Dependency on glfw@any version already satisfied
Info: Dependency on glm@any version already satisfied
Reading official package list
Reading official package list
Reading official package list
Building tgraphics/tutorial_glfw3/minimal using c backend
Info: compiling nim package using /home/hmf/.nimble/bin/nim
Executing /home/hmf/.nimble/bin/nim c --colors:on --noNimblePath -d:glfwStaticLib -d:NimblePkgVersion=0.1.0 --path:/home/hmf/.nimble/pkgs2/glfw-3.4.0.5-c3e9fa513a5cd1a3cd685d585cd321cb4971e2ca --path:/home/hmf/.nimble/pkgs2/glm-1.1.1-4f488f67e5a3c45d3483e1d60a8f52acc8453a8a -o:/home/hmf_x/VSCodeProjects/nim_learn/tgraphics/bin/tutorial_glfw3/minimal /home/hmf_x/VSCodeProjects/nim_learn/tgraphics/src/tutorial_glfw3/minimal.nim
Nim Output Hint: used config file '/home/hmf/.choosenim/toolchains/nim-2.2.4/config/nim.cfg' [Conf]
... Hint: used config file '/home/hmf/.choosenim/toolchains/nim-2.2.4/config/config.nims' [Conf]
... Hint: used config file '/home/hmf_x/VSCodeProjects/nim_learn/tgraphics/config.nims' [Conf]
... .........................................................................................................................
... Hint: [Link]
... Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
... 69632 lines; 0.977s; 91.824MiB peakmem; proj: /home/hmf_x/VSCodeProjects/nim_learn/tgraphics/src/tutorial_glfw3/minimal.nim; out: /home/hmf_x/VSCodeProjects/nim_learn/tgraphics/bin/tutorial_glfw3/minimal [SuccessX]
Info: Nimble data file "/home/hmf/.nimble/nimbledata2.json" has been saved.
However, I have set up the following task:
task buildAll, "Build all binaries":
selfExec("build -d:glfwStaticLib src/tutorial_glfw3/minimal.nim tutorial_glfw3/minimal")
and when I execute the command:
$ nimble --verbose buildAll
I get:
Info: Package cache path /home/hmf/.nimble/pkgcache
Info: Nimble data file "/home/hmf/.nimble/nimbledata2.json" has been loaded.
Info: Dependency on nim@>= 0.17.2 already satisfied
Info: Dependency on nim@>= 2.0.8 already satisfied
Info: Dependency on nim@>= 2.2.4 already satisfied
Info: Dependency on glfw@any version already satisfied
Info: Dependency on glm@any version already satisfied
Reading official package list
Reading official package list
Reading official package list
Executing task buildAll in /home/hmf_x/VSCodeProjects/nim_learn/tgraphics/tgraphics.nimble
Working ⣽
Hint: used config file '/home/hmf/.choosenim/toolchains/nim-2.2.4/config/nim.cfg' [Conf]
Hint: used config file '/home/hmf/.choosenim/toolchains/nim-2.2.4/config/config.nims' [Conf]
Hint: used config file '/home/hmf_x/VSCodeProjects/nim_learn/tgraphics/config.nims' [Conf]
..................................................................................................................
/home/hmf_x/VSCodeProjects/nim_learn/tgraphics/src/tutorial_glfw3/minimal.nim(6, 8) Error: cannot open file: glfw
stack trace: (most recent call last)
/tmp/nimblecache-6745848478940229432/nimscriptapi_8530934503908121904.nim(216, 16)
/home/hmf_x/VSCodeProjects/nim_learn/tgraphics/tgraphics.nimble(33, 11) buildAllTask
/home/hmf/.choosenim/toolchains/nim-2.2.4/lib/system/nimscript.nim(290, 7) selfExec
/home/hmf/.choosenim/toolchains/nim-2.2.4/lib/system/nimscript.nim(290, 7) Error: unhandled exception: FAILED: /home/hmf/.choosenim/toolchains/nim-2.2.4/bin/nim build -d:glfwStaticLib src/tutorial_glfw3/minimal.nim tutorial_glfw3/minimal [OSError]
nimscriptwrapper.nim(166) execScript
Error: Exception raised during nimble script execution
Info: Nimble data file "/home/hmf/.nimble/nimbledata2.json" has been saved.
I see that the --path is not added to the command line generated by the Nimble task (in fact none of the other nimble elements are added to the command line). I am using VScode with the Nim extension, and the IDE too complains it cannot load the file. How should one define such a build task? I had assumed the requires of the nimble script would handle this automatically. Note that I am on an Ubuntu OS.
TIA
/home/hmf/.choosenim/toolchains/nim-2.2.4/bin/nim build -d:glfwStaticLib src/tutorial_glfw3/minimal.nim tutorial_glfw3/minimal [OSError]
selfExec() runs command with nim, but you need nimble, so instead use:
task buildAll, "Build all binaries":
exec("nimble build -d:glfwStaticLib src/tutorial_glfw3/minimal.nim tutorial_glfw3/minimal")
Also, you can setup paths for nim compiler by running nimble setup in project directory.
@janAkali Thank you. Solved my issue. Apologies, but I don't seem to able to flag your reply as the correct answer.
As for the simble setup command I am re.reading the Nimble docs on this.
Thanks again.