Closed vimkim closed 6 years ago
This happens because YCM-Gen runs with a different PATH. Specifically, it places this directory at the start of the PATH, and relies on the compiler used being present there. We then set the CC
variable which is what Make uses to determine which compiler to use. If you set the CC
variable inside the Makefile, that will override our value and break it. (It will also be non-portable to other OSs which don't use that filename for GCC 7.)
To workaround this, you can either stop setting CC
in your makefile, or use the option --make-flags="--environment-overrides"
to give priority to the environment variable.
Longer-term, #97 will solve this, so I'll close this as a duplicate.
Just a small tip for those in the future who would stumble upon the same problem as I did.
Everyone who are familiar with brew gcc might be aware of that, when installing gcc and g++ via brew, their symbolic links are named: gcc-7 and g++-7 instead of gcc and g++.
Therefore I tend to write CC=gcc-7 instead of CC=gcc inside of a Makefile as I would like to use the latest gcc instead of the mac-builtin version.
Such Makefile seems to work fine when run in shell (by typing $ make), however, this causes 'ERROR: no commands were logged... ' when invoked by YCM-generator.
While debugging, I happened to change CC=gcc-7 to CC=gcc and then it worked normal, and I was happy to figure this out so I write this here.
Hopefully YCM-generator can identify 'gcc-7' and 'g++-7' in the future, or at least those people who experience the same problem can see this post and change their Makefile.
I hope somebody would close this issue once the problem is solved (i.e. YCM-generator understands 'CC=gcc-7') or if it is difficult to fix, then just close it.
Thanks for the nice plugin!
By the way, as a temporary amendment, I just decided to create the following symbolic link to solve this problem and use gcc-7 at the same time.