Hi there o/ I'm pretty new in nim but have actually programming knowledge for 10+ years. I almost avoided C++ / C completly during my career because I never quite understand how the toolchains and the compiler works. It was to much of a hussle and I still get big questions marks. Anyways, I have some troubles with building a simple nim program in windows for 32 bit. My development machine runs on 64 bit.
What did I do? Actually, I just downloaded nim and put it into C:nim-1.4.2 and run the finish.exe - It asked if I wanted to download the mingw64 from the download side: https://nim-lang.org/install_windows.html
Surely, I just said yes. It compiles for 64 bit pretty fine:
echo "example"
nim c example.nim
This works fine, however if I try now to compile it for 32 bit I get a bunch of console outputs and an error in the end:
nim c --cpu:i386 -t:-m32 -l:-m32 example.nim
execution of an external program failed: 'C:\nim-1.4.2\dist\mingw64\bin\gcc.exe
I really don't know so much about the gcc compiler and avoid it until today so far. But honestly - I'm stuck. I don't know what causes this and what -m32 is even supposed to mean. A quick google to that just told me I need it to say the compiler that I want a 32 bit version of my software. But why doesn't it work? I didn't change anything with the installation.
I'm currently in the process of learning how to use a compiler. The languages I used had some nice IDE which all hide this stuff from me. And mostly script languages ofc :P Anyways - can someone help me out and explain what is going on?
Nevermind :)
I found a solution to it. Actually, I downloaded mingw32 from the download page and put it into the dist folder. I just added a config file:
# nim.cfg
@if windows:
@if amd64:
gcc.path = r"$nim\dist\mingw64\bin"
@elif i386:
gcc.path = r"$nim\dist\mingw32\bin"
@end
@end
I can use now the following commands
nim c --cpu:amd64 example.nim
nim c --cpu:i386 example.nim
to compile my software in either 64 or 32 bit.