Bumped into a problem with multiple gcc installations. I wanted to force the use of gcc-2.95 but I couldn’t use the normal ‘update-alternatives’ script because the package wasn’t being managed by it. I tryed another approach that was to put a copy of the gcc binary I wanted, together with ‘cpp0’ and ‘cc1’, on ~/bin and added it to PATH. I then tryed to compile a minimal C file:
main(){}
But then I was having this error:
ld: crtbegin.o: No such file or directory
GCC searches the PATH for an assembler and a loader, but it only does so after searching a directory list hard-coded in the GCC executables. By issuing ‘gcc –print-search-dirs’ you can check that list. By doing this I found that I needed to include yet another directory and by exporting LIBRARY_PATH to that directory I was able to make it work.
This problem eated most of my day so I hope this saves someone (or me next time) some time.
**Note:** If after this you have problems with the headers you may need to pass to gcc in the compilation command the directory of the headers you want with the option -I.