Hi guys,
Currently I'm trying to create a portable coding environment with nim, and recently downloaded a pre-build runtime of compilers pack from https://github.com/theopolis/build-anywhere.
I've tried g++ and indeed it correctly compiles c++ files.
I've shortend names and tried again and it still worked.
So i decided to try --cc option from nim to change default compiler. I provided path to compiler:
nim --cc:~/compilers/bin/g++ cpp --compile_only ~/jsparser.nim
But then that happend:
command line(1, 2) Error: unknown C compiler: '~/compilers/bin/g++'
Again, outside of nim it works well. Anyone tried something similar? How to attach different compiler? I just want to run it via nim cli, do I need to manually edit nim.cfg?
Using Nim 0.19.9 from April 1.
--cc is the commend to choose your compiler, those are predefined (gcc, clang, vcc, ...).
If you want to specify your gcc executable you need to pass --gcc.cpp.exe: for C++ compilation or gcc.exe: for C compilation.
So your command line should be:
nim --gcc.cpp.exe:~/compilers/bin/g++ cpp --compile_only ~/jsparser.nim
I followed your advice but nothing happens. I've tried different entries and once even provided wrong path, every time the compilation is successfull , but without using my portable compilers, just like all the time it used default compiler. I even removed cpp from command as to prevent default c++ compiler but then compilation fails.
sebastian@linux-98w3:~> nim --gcc.cpp:~/compilers/bin/x86_64-anywhere-linux-gnu-g++ ./jsparser.nim
Hint: used config file '/home/sebastian/nim/config/nim.cfg' [Conf] Hint: used config file '/home/sebastian/nim/config/config.nims' [Conf] Error: invalid command: ./jsparser.nim
I tried also to skip cfg but result was the same. Cleaning cache folder also didn't help.
What Am I doing wrong?
What Am I doing wrong?
There is a remark at the bottom of the FAQ:
But I can not help you, have only switched between gcc and clang.
Your command is incomplete, you are missing the cpp command and the .exe in gcc.cpp.exe:
nim --gcc.cpp:~/compilers/bin/x86_64-anywhere-linux-gnu-g++ ./jsparser.nim
versus
nim --gcc.cpp.exe:~/compilers/bin/x86_64-anywhere-linux-gnu-g++ cpp ./jsparser.nim
Stefan,
All my compilers are supported, and in fact I missed exe from -gcc.cpp.exe because I thought that it's reffering to Windows OS, but after adding it:
sebastian@linux-98w3:~> nim --gcc.cpp.exe:~/compilers/bin/x86_64-anywhere-linux-gnu-g++ cpp ./jsparser.nim
The compilation starts but fails somewhere after listing nim packages with:
Error: execution of an external compiler program ''~/compilers/bin/x86_64-anywhere-linux-gnu-g++' -c -w -w -fpermissive -I/home/sebastian/nim/lib -I/home/sebastian -o /home/sebastian/.cache/nim/jsparser_d/stdlib_assertions.cpp.o /home/sebastian/.cache/nim/jsparser_d/stdlib_assertions.cpp' failed with exit code: 127
But the file exist, and works.I've added ~/compilers/bin folder to my $PATH but nothing happened.