Search code examples
ubuntugccpythonanywhere

Permission Denied error while building gcc in PythonAnyWhere


I'm trying to build the gcc-7.4.0 in PythonAnyWhere. I downloaded the gcc-7.4.0 via wget and I ran the following commands successfully.

~ $ mkdir gccbuild

~ $ cd gccbuild

~/gccbuild $ ../gcc-7.4.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-7.4.0 --enable-checking=release --enable-languages=c,c++,fortran 
--disable-multilib --program-suffix=-7.4

~/gccbuild $ make -j 8

Now I'm trying to run the make install-strip command but it gives a Permission denied error such as below.

make[1]: Entering directory '/home/sfmyazilim/gccbuild'
/bin/bash ../gcc-7.4.0/mkinstalldirs /usr/local/gcc-7.4.0 /usr/local/gcc-7.4.0
mkdir -p -- /usr/local/gcc-7.4.0 /usr/local/gcc-7.4.0
mkdir: cannot create directory ‘/usr/local/gcc-7.4.0’: Permission denied
mkdir: cannot create directory ‘/usr/local/gcc-7.4.0’: Permission denied
Makefile:2581: recipe for target 'installdirs' failed
make[1]: *** [installdirs] Error 1
make[1]: Leaving directory '/home/sfmyazilim/gccbuild'
Makefile:2491: recipe for target 'install-strip' failed
make: *** [install-strip] Error 2

I cannot use sudo because PythonAnyWhere doesn't allow it. How can I install the built GCC via the make install-strip command without any errors?


Solution

  • When you run the configure command, you can set the directory for installation with the --prefix flag, so you need to add on something like --prefix=$HOME/.local to that so that it will install to your home directory's .local subdirectory, which is the standard place for user-specific binaries like this. So you should go through the process again, configuring with that additional parameter, making the binaries with the make -j 8 command, and then run the make install step.