Nim: .nim files cannot compile on windows 10 x64 nim version 0.14.2_x64

Created on 7 Jul 2016  路  6Comments  路  Source: nim-lang/Nim

I was going through the Nim tutorial at http://nim-lang.org/docs/tut1.html
and can never get a program to compile.

I get;

C:\Users\user\Desktop\nim>nim compile --run greetings.nim
Hint: used config file 'C:\Nim\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: greetings [Processing]
CC: greetings
CC: stdlib_system
In file included from c:\users\user\desktop\nim\nimcache\stdlib_system.c:9:0:
C:\Nim\lib/nimbase.h:456:13: error: size of array 'assert_numbits' is negative
 typedef int asIsne rfti_lneu mibnictlsu[dseidz eforfo(mN Ic): \=u=s esrisz\eaosf1(nvdoui\dd*e)s k&t&o pN\InMi_mI\NnTiBmIcTaSc h=e=\ gsriezeetoifn(gNsI.)c*8 ? 1 : -1];
         : 9 : 0 :^

C:\Nim\lib/nimbase.h:456:13: error: size of array 'assert_numbits' is negative
 typedef int assert_numbits[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
             ^
Hint:  [Link]
gcc.exe: error: c:\users\user\desktop\nim\nimcache\stdlib_system.o: No such file or directory
gcc.exe: error: c:\users\user\desktop\nim\nimcache\greetings.o: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
Error: execution of an external program failed: 'gcc.exe   -o c:\users\user\desktop\nim\greetings.exe  c:\users\user\desktop\nim\nimcache\stdlib_system.o c:\users\user\desktop\nim\nimcache\greetings.o  '


Also installing packages with nimble e.g nimble install nake
thwows an error, Error: unhandled exception: Build failed for package: nimsuggest [BuildFailed]

I have MinGNU in my path.

What could be the problem?

Most helpful comment

@Araq perhaps one of the identifiers on that assertion line could be changed to become a message? Like 'Nim_and_C_compiler_disagree_on_target_architecture'? Either that, or the Nim compiler could scan for the error in output and display a supplementary message.

All 6 comments

This is the error you get when your Nim compiler and C compiler are trying to compile executables for different target architectures (they need to target the same architecture to work together successfully).

This is commonly caused by downloading a 64-bit Nim compiler and using MinGW, rather than MinGW-w64. The Nim compiler targets the architecture it was built for by default (such as 64-bit systems), while MinGW targets 32-bit systems by default.

I recommend either downloading the correct version of Nim, using the version of MinGW-w64 that comes with the installer, or downloading MinGW-w64 separately.

Fix your environment. Nim on Win 10 works perfectly fine, I use it all the time.

@Araq perhaps one of the identifiers on that assertion line could be changed to become a message? Like 'Nim_and_C_compiler_disagree_on_target_architecture'? Either that, or the Nim compiler could scan for the error in output and display a supplementary message.

@Varriount 's solution worked.. thanx...

I believe there is room for improvement regarding this behavior.

When a programming environment says "array size something is negative" when the user tries to compile hello-world source it doesn't look good. Yes the experienced people will probably figure out. But the users who decided to try the language out for the first time might decide to leave it at that. The cryptic error message might look especially off-putting for beginners & students.

@hinstw nim already does that, this array now is literally named Nim_and_C_compiler_disagree_on_target_architecture

Was this page helpful?
0 / 5 - 0 ratings