Gcc error trying to execute exec 'cc1': execvp: no such file or directory when running with non-root user
I see that the same question has been asked many times, but my problem is different.
I have installed gcc on ubuntu 14.04 and it works fine with root user. When I try to compile using a non-root user it throws
gcc error: error trying to execute exec 'cc1': execvp: no such file or directory
After compiling the file with the root user, a non-root user can execute the file without any error, but he will not be able to compile the file.
I suspect there is a file permissions issue and I checked the permissions for cc1 and the root user did not have execute permission on the file.
source to share
First way:
In the account, root
use the command:
which gcc
which cc1
ls -l $ Output of the previous command
It will show you where cc1
and gcc
and the permissions are cc1
Make sure you have permissions on the cc1
file
Then, under the "regular" user:
which gcc
The output which gcc
should be the same as for root.
If the right is ok and the path to is gcc
the same as in root
, add PATH
in cc1
for user.
Second way:
Account root
:
gcc -v hello_world.c 2> & 1 | grep cc1
And do the same under the "regular" account.
It will show you the real commands that were used to compile.
Compare them and check the rights and PATH
as in the first case
To add using PATH: export PATH=$PATH:$add_new_path_to_folder_here
source to share
In my case, this error occurred while trying to compile an updated version of ffi, nokogiri and other stones on Ubuntu. gcc -v
shown that I was using gcc and g ++ 4.8.
The fix was to switch my gcc / g ++ references to use 4.9 instead of 4.8.
$ which gcc
$ ls -ld /usr/local/bin/gcc
$ sudo rm /usr/local/bin/gcc
$ sudo ln -s /usr/bin/gcc-4.9 /usr/local/bin/gcc
$ ls -ld /usr/local/bin/gcc
Repeat for g ++.
source to share