I see that same question has been asked many times but my problem is different.
I installed gcc on ubuntu 14.04 and and it works fine with root user. When I attempt to compile using non-root user it throws
error gcc: error trying to exec 'cc1': execvp: No such file or directory
Once I compile the file with root user, non-root user is able to execute the file without any error but it is not able to compile the file.
I suspect there is a problem with file permissions and I have checked permissions for cc1 and non root user had execute permission on the file.
Under the root
account use the command:
which gcc
which cc1
ls -l $Output of previous command
It will show you where are cc1
and gcc
and rights of cc1
Check that you have proper rights for cc1
file
Then under "regular" user:
which gcc
Output of which gcc
should be the same as for root.
If right is ok and path to gcc
the same as under the root
, add PATH
to cc1
for user.
Under the root
account:
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 was used for compilation.
Compare them and check rights and PATH
as in first way
To add PATH use: export PATH=$PATH:$add_new_path_to_folder_here
In my case, this error was occurring while attempting to compile an updated version of ffi, nokogiri and other gems on Ubuntu. gcc -v
revealed I was using gcc and g++ 4.8.
The fix was to switch my gcc/g++ symlinks 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++.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.