I have a C++ project and I want to use my Nim library so I'm trying to compile a static library but I'm getting this error on windows:
Hint: [Link]
Error: invocation of external linker program failed. The system cannot find the file specified.
2
I'm just doing nim --app:staticLib --noMain c <module> as described in the manual page
Also as a side note, does anyone have any examples of using a Nim library in a C/C++ application? Most examples I've seen of backend integration tend to be wrappers, ie Nim code calling backend code, but I'm interested in the reverse.
In default Nim uses GCC as backend compiler on windows and use ar in Binutils to make static library. Binutils should be installed when you install GCC but that error message seems ar is missing or not in %PATH%. --listcmd option shows commands that Nim calls to run backend C compiler and linker. That might help you to find which program is missing on your system.
My article might help you: https://internet-of-tomohiro.netlify.app/nim/clibrary.en.html
Ah perfect, didn't realize --listcmd was a thing. Yup, ar wasn't in my path, adding the mingw toolchain downloaded by choosenim to my PATH fixed it.
And when using --cc:vcc you'll have to run nim via the visual studio developer command prompt since it uses lib