gcc48 error on Mavericks

Brandon Allbery allbery.b at gmail.com
Fri Jan 10 22:06:37 PST 2014


On Sat, Jan 11, 2014 at 12:56 AM, Shiyuan <gshy2014 at gmail.com> wrote:

> There is another problem regarding to the coexistence of xcode gcc and
> gcc48 from macports.
> When I do  "port select gcc mp-gcc48" , I can compile using "g++". But
> when I switch back by "port select gcc none",
> I got the error:
>
> > g++ -g -o HelloWorld HelloWorld.cpp
>
> -bash: /opt/local/bin/g++: No such file or directory
>
> But strangely, when I do "which g++",  I get "/usr/bin/g++". Then why
> "g++" still try to involve "/opt/local/bin/g++" but not "/usr/bin/g++"?
>

`which` is often not a shell builtin and/or not using what your current
shell's state is, and will often show you not what your current shell sees
but what a new shell would see (or, in older versions especially with *csh,
what you would see if you logged out and back in). You should not rely on
it. `type` shows you (and is required by POSIX to show you) what the
current shell "knows", not what it would find if it were restarted.

In this case, the problem is that bash remembers where it found a command,
rather than looking again for it every single time; you need to use `hash
-r` to make it forget that it once saw /opt/local/bin/g++ so it will go
find out that /usr/bin/g++ is currently the only one on $PATH. (Actually
setting $PATH will do this automatically; removing an executable found
somewhere on $PATH originally does not.)

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-users/attachments/20140111/1763b5ab/attachment.html>


More information about the macports-users mailing list