Search code examples
gccpipg++cupy

How to specify a gcc path in pip command?


I am trying to install cupy 5.0.0. cupy5.0.0 needs gcc version not more than 7. My deafault gcc is gcc-9. I cannot use conda environment. Also i dont have sudo permission to change /usr/bin/gcc to point to gcc-7. Is there any way to pass gcc path to pip command?


Solution

  • You can use CXX, CC and LD environment variables to specify executable names or full paths to C++ and C compilers, and the linker.

    Specify the variables only for one command:

    CXX=g++-7 CC=gcc-7 LD=g++-7 pip install ...
    

    Alternatively:

    export CXX=g++-7 
    export CC=gcc-7
    export LD=g++-7 
    pip install ...
    

    You can also pass extra compiler and linker options in CXXFLAGS, CFLAGS, LDFLAGS. Preprocessor options (e.g. include directories) go in CPPFLAGS.