5

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.

7
  • The error message thrown on running gcc is given in the title. I have explained that file 'cc1' exists and user has permissions to the file. Please tell me what details you need. Commented May 20, 2015 at 8:29
  • 1
    You might want to strace the compile and see exactly what problems the system runs into looking for cc1: strace gcc -c foo.c 2>&1 | grep cc1 Commented May 20, 2015 at 8:39
  • 1
    How did you install gcc ? What is the command you're running that produces this error ? What does gcc -v reveal ? Please check which gcc binary you're actually running, in case you've somehow installed different gcc versions at different places. Commented May 20, 2015 at 8:40
  • Also, GCC's -v option might be helpful. Commented May 20, 2015 at 8:40
  • You may not have build-essential. Try installing it: sudo apt-get install build-essential Commented May 20, 2015 at 8:45

2 Answers 2

4

First way:

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.

Second way:

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

Sign up to request clarification or add additional context in comments.

Comments

1

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++.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.