0

I can compile using icc just fine:

akady@TermintX ~/Test $ icc HelloWorld.c

akady@TermintX ~/Test $ ls

a.out HelloWorld.c

akady@TermintX ~/Test $ ./a.out

Hello World

But when trying the same thing with sudo:

akady@TermintX ~/Test $ sudo icc HelloWorld.c

[sudo] password for akady:

sudo: icc: command not found

(Though gcc works fine, both with and without sudo)

2 Answers2

3
  1. Seems like icc is not in your default path.
  2. why compile as root ?

If you REALLY need to compile as root (which i can't think of any reason why) add icc path to the PATH variable (best place would be in his profile)

 export PATH="/opt/intel/blabla/bin:${PATH}"
Rabin
  • 3,883
  • 1
  • 22
  • 23
  • I am trying to install openMPI and it gives an error about permissions without using sudo and an error about icc with it, though at a later stage. – Pyrphoros Sep 05 '16 at 06:30
  • you only need root privileges to install the application to the system, but you don't need it for compiling it. – Rabin Sep 05 '16 at 06:34
  • The errors come up in the make all install stage. It gives a similar error about icc not found. I can't figure out just how to go about adding the path to icc, nothing seems to work. Apologies if this is trivial, I am a bit new to linux. – Pyrphoros Sep 05 '16 at 06:42
  • 4
    @Pyrphoros First do make all as an ordinary user, then sudo make install to install the result. Each argument to make is a separate target that you can do independently. – meuh Sep 05 '16 at 07:42
-2

What finally solved the issue was using sudo -s and then calling icc.

Archemar
  • 31,554
  • This makes no difference for me - the -s option means "use user's own shell" (either from $SHELL or the passwd file). What shell are you using? – JigglyNaga Sep 05 '16 at 08:56
  • I am using bash. – Pyrphoros Sep 05 '16 at 17:37
  • 2
    Then you should remove your PATH settings from .bashrc and put them in .profile where they belong. See http://unix.stackexchange.com/questions/3052/is-there-a-bashrc-equivalent-file-read-by-all-shells and a zillion other similar questions on this site. – Gilles 'SO- stop being evil' Sep 05 '16 at 22:47