<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jan 11, 2014 at 12:56 AM, Shiyuan <span dir="ltr"><<a href="mailto:gshy2014@gmail.com" target="_blank">gshy2014@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There is another problem regarding to the coexistence of xcode gcc and gcc48 from macports. <div>When I do "port select gcc mp-gcc48" , I can compile using "g++". But when I switch back by "port select gcc none", </div>
<div>I got the error: </div><div>
<p>> g++ -g -o HelloWorld HelloWorld.cpp</p>
<p>-bash: /opt/local/bin/g++: No such file or directory</p><p>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++"? </p>
</div></div></blockquote><div> </div><div>`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.</div>
<div><br></div><div>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.)</div>
<div><br></div></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div></div>