Not the best idea in general, because these two are tightly integrated and there is a reason GCC has its own search paths with the appropriate tools for that particular build of GCC, so it's better to switch toolchain as a whole.
Anyway, the link provided by Jean-François Fabre is right in its -B
parameter suggestion and not so right about PATH
environment variable, because PATH
is only searched when there is no match in GCCs internal paths, and usually there is something there.
You can take a look at the current paths used by GCC to find its components with g++ -print-search-dirs
, you're interested in programs
. It's also easy to check where exactly your compiler finds ld
(or any other component) with g++ -print-prog-name=ld
, it also allows to check how -B
affects the result, like:
$ g++ -print-prog-name=ld
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld
$ g++ -B/home/rik/bin -print-prog-name=ld
/home/rik/bin/ld
Compare that to
$ PATH=/home/rik/bin:$PATH g++ -print-prog-name=ld
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld
[edit]
And BTW, even this won't help you if your GCC was specifically configured using --with-ld
option (not the usual way, but), that overrides all other paths.