我写了一个尼姆程序,
echo("Hello.")然后我试图交叉编译一个Linux机器,
nim c --cpu:i386 --os:linux -c hello.nim这产生了以下产出:
config/nim.cfg(45, 2) Hint: added path: '/Users/connor/.babel/pkgs/' [Path]
config/nim.cfg(46, 2) Hint: added path: '/Users/connor/.nimble/pkgs/' [Path]
Hint: used config file '/usr/local/lib/nim-0.10.2/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
Hint: operation successful (8753 lines compiled; 0.140 sec total; 14.148MB)[SuccessX]此时,我更改为nimcache/目录,并尝试执行:
gcc hello.c -o hello.o但这给了我一个错误:
hello.c:5:10: fatal error: 'nimbase.h' file not found
#include "nimbase.h"
^
1 error generated.我想,“没什么大不了的,我只需要找到nimbase.h并把它放在nimcache目录中,”但是在那之后我得到了一个新的错误,
In file included from hello.c:5:
./nimbase.h:385:28: error: 'assert_numbits' declared as an array with a
negative size
...sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.我不知道该拿它做什么。我曾尝试使用--genScript选项,但这导致了类似的错误。我在运行。
谢谢!
更新:
我不确定--cpu:选项支持多少个体系结构,但我找到了一个(部分?)是什么使尼姆成为现实博客上的列表。最后我打了电话,
nim c --cpu:amd64 --os:linux -c hello.nim这防止了我在Linux机器上编译时看到的错误。如果您使用的是Linux或OS,不确定您可以调用什么CPU架构,
less /proc/cpuinfo发布于 2015-04-29 07:36:18
最后一个问题是,您正在为x86_64 arch运行gcc,而源是为i386 arch生成的。
发布于 2016-06-14 16:05:38
我在让nim从GNU/Linux机器为Windows编译可执行文件时遇到了同样的问题,所以我编写了一个bash脚本。它接受到包含*.nim源文件的目录的路径和要输出的可执行文件的名称。
我相信您可以交换GCC编译器(在本例中为MinGW),并酌情更改--os:开关:
#!/usr/bin/env bash
# Nim must generate C sources only, to be fed to MingW
nim c --cpu:amd64 --os:windows --opt:speed --embedsrc --threads:on --checks:on -c -d:release $1/*.nim
# Copy nimbase.h so MingW32 can find it during compilation and linking
cp /opt/Nim/lib/nimbase.h $1/nimcache/nimbase.h
mkdir -p $1/bin
cd $1/nimcache && x86_64-w64-mingw32-gcc -save-temps $1/nimcache/*.c -o $1/bin/$2.exe
rm $1/nimcache/*.{i,s} # only care about *.o objects
ls -lAhF $1/nimcache
ls -lAhF $1/binhttps://stackoverflow.com/questions/29935580
复制相似问题