symlink confusion

Joshua Judson Rosen rozzin at hackerposse.com
Sat Nov 14 16:07:28 EST 2015


Bruce Labitt <bruce.labitt at myfairpoint.net> wrote:
>
>Pardon my denseness (density?), but what you have shown is still 
>confusing to me.
>
>ln -s thing-I-want-a-symlink-to where-I-want-to-put-it  <-- I don't 
>understand this :(
>
>In my case, I want any reference to cc to point to 
>/opt/compiler_cuda/gcc.  It turns out /opt/compiler_cuda/gcc will be a 
>symlink as well.  Eventually the cc reference will end up pointing to 
>gcc-4.9, since CUDA7.5 does not support gcc5.
>
>Is it
>1)  ln -s cc /opt/compiler_cuda/gcc      or
>2)  ln -s /opt/compiler_cuda/gcc cc
>
>Which one does what I want?  Seriously confused.

I suspect you don't quite want either of those, actually.

It sounds a little like you're expecting "ln -s" to create a shell
command-alias or something (you never said *what directory* you want
to contain the "cc" symlink, but that's important!). It just creates a file.
In order for that file to be recognised as a command, you need to put it
in one of the directories that the shell searches ($PATH).

IF you want to used a symlink to create a "cc" command, you probably want
either:

        ln -s /opt/compiler_cuda/gcc /usr/local/bin/cc

... or:

        ln -s /opt/compiler_cuda/gcc ~/bin/cc

... depending on whether you're doing this for a system-wide default
or just for yourself. But I'm surprised that you're trying to do it
this way at all.

I usually just do something more like:

        export CC=/opt/compiler_cuda/gcc

... and then let the makefiles pick up that environment-variable.
Even if your Makefile is using implicit rules, it'll still pick up
and use the ${CC} value from your environment.

Are you actually using a Makefile or something that actually,
*explicitly*, has "cc" hardcoded rather than using "${CC}"?

I'd expect that you don't actually want to make a CUDA compiler
the default compiler for *all software* you build,
which is probably what you'll do by naming it "cc"
and putting it into your search-path....


More information about the gnhlug-discuss mailing list