Hello everyone, I've installed successfully zip 0.3.1 with Nimble on Windows. I'm using Nim release is 1.6.0 (but I have same problem on another PC with Nim 1.4.4). When trying to build a program importing zip module, it fails. Minimal code to trigger the problem is:
import zip/zipfiles
then I get:
PS C:UsersAndrea> nim c -r "c:UsersAndreaDocumentsNimworking_codezip_import.nim" Hint: used config file 'C:UsersAndrea.choosenimtoolchainsnim-1.6.0confignim.cfg' [Conf] Hint: used config file 'C:UsersAndrea.choosenimtoolchainsnim-1.6.0configconfig.nims' [Conf]
c:UsersAndreaDocumentsNimworking_codezip_import.nim(1, 11) Warning: imported and not used: 'zipfiles' [UnusedImport] CC: libzip_all CC: stdlib_digitsutils.nim CC: stdlib_assertions.nim CC: stdlib_dollars.nim
compilation terminated. Error: execution of an external compiler program 'gcc.exe -c -w -fmax-errors=3 -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN -IC:UsersAndrea.choosenimtoolchainsnim-1.6.0lib -Ic:UsersAndreaDocumentsNimworking_code -o C:UsersAndreanimcachezip_import_dlibzip_all.c.o C:UsersAndrea.nimblepkgszip-0.3.1zipprivatelibzip_all.c' failed with exit code: 1
Did I execute something wrong (I'm not very solid on Nim...)? Thank you.
Please put code pastes in code blocks so they're a bit more readable.
This appears to be an issue with not passing the correct imports to Nim. Essentially you need to install zlib and then use passC/passL with the correct path to zlib so that Nim can find zlib.h.
Sorry, I send it again in code block:
PS C:\Users\Andrea> nim c -r "c:\Users\Andrea\Documents\Nim\working_code\zip_import.nim"
Hint: used config file 'C:\Users\Andrea\.choosenim\toolchains\nim-1.6.0\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\Andrea\.choosenim\toolchains\nim-1.6.0\config\config.nims' [Conf]
c:\Users\Andrea\Documents\Nim\working_code\zip_import.nim(1, 11) Warning: imported and not used: 'zipfiles' [UnusedImport]
CC: libzip_all
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: stdlib_dynlib.nim
C:\Users\Andrea\.nimble\pkgs\zip-0.3.1\zip\private\libzip_all.c:34:10: fatal error: zlib.h: No such file or directory
34 | #include <zlib.h>
| ^~~~~~~~
compilation terminated.
Error: execution of an external compiler program 'gcc.exe -c -w -fmax-errors=3 -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN -IC:\Users\Andrea\.choosenim\toolchains\nim-1.6.0\lib -Ic:\Users\Andrea\Documents\Nim\working_code -o C:\Users\Andrea\nimcache\zip_import_d\libzip_all.c.o C:\Users\Andrea\.nimble\pkgs\zip-0.3.1\zip\private\libzip_all.c' failed with exit code: 1
I thought that nimble installation command took care of all dependencies, including DLLs and C headers file. So I got it wrong, and I understand that there is something I have to complete manually.
If I dig on package directory I find
\.nimble\pkgs\zip-0.3.1\zip\private\libzip_all.c
So at least .c file is there. Should I add the zlib.h file myself? In the same folder? Where I should pick up the right one (I mean the appropriate version)? If you have some "C library Nim's wrapper installation guide for dummies" to point out, please do it, I don't want to bother community with too lame questions. There is also another wrapper I would like to install, xlsxio, but the documentation states:
NOTE: You should have xlsxio_write and xlsxio_read installed in your system in a way nim can infer their locations (either by path or cli switches). This wrapper won't compile without them.
And I need to understand what files I have to fetch and where to put them, to complete C wrapper package installation after nimble install step. Thank you
{.passL: "-lxlsxio_read".}
{.passL: "-lxlsxio_write".}
is written in https://github.com/jiiihpeeh/xlsxio-nim/blob/main/src/xlsxio.nim, so you need at least xlsxio_read.dll and xlsxio_write.dll. However, {.header: "".} is not seen, so I don't think xlsxio needs header to compile. You may place the .dll in the same dir as your source files and add {.passL: "-L.".} to your code, so the C compiler knows where to search for the dll.