cc and gcc coexisting
Hello all:
I hope someone out there can help allay my fears and confirm my conclusions.
Is it possible to have both the Sun Studio compilers and gcc installed, but keep gcc as the default compiler through 'cc' on the command line?
I have third party software that uses gcc (and a few hundred shell scripts that call it via 'cc') exclusively to compile its processes. However, I need to use the Sun Studio suite for other things on the same systems. I think I can install the Sun packages and configure them to only work when the fully-qualified pathname is used to call them, and keep gcc available as it is now. However, since I've never done this, and I'm not an expert, I thought I would float this to see if anyone out there can say yea or neigh.
If you have any thoughts, I would greatly appreciate them.
Thank you.
[864 byte] By [
MRI_guy] at [2007-11-26 9:05:17]

# 1
You can install Sun Studio and gcc on the same system. The gnu tools are usually installed in /usr/local or /usr/sfw. Sun Studio by default installs in /opt. You can install Sun Studio somewhere else, but be sure you do not install it in the same location as gnu tools.
If you want to use "cc" to invoke gcc (not recommended, but you might not have a choice), create a symbolic link "cc" in a convenient directory D that points to gcc.
If directory D is on your $PATH ahead of (or instead of) the Sun Studio bin directory, the command "cc" will invoke gcc.
If the Sun Studio bin directory is on your $PATH ahead of (or instead of) the directory D, the command "cc" will invoke the Sun C compiler.
A more usual solution to having muliple compiles is to use a CC macro in makefiles, and set the macro to the full path to gcc or Sun cc. Don't use "cc" in the makefiles; use ${CC} instead. This technique avoids the need to change your $PATH frequently.
A "cc" command also exists in /usr/ucb. If you have /usr/ucb on your $PATH, be sure it is after the two directories mentioned above.
# 2
What you suggest should work fine, MRI_guy.
As Steve said, when you want to use Sun Studio it's best
to set up the Makefiles to use the full path to the compiler.
If you are going to run a lot of sun studio tools during a session,
then it's best to set up your PATH variable in one specific shell
window so that Sun Studio comes first before the system 'cc'.
If you run GUI tools from a window where PATH is set to Sun Studio, the
GUI tools will inherit that search path, and use the same preference.
# 3
Thanks for your help. This is exactly what I hoped to hear.
I agree that bypassing cc and linking it to gcc is not the best thing in the world, but my
third party packages (the whole reasons for having these systems in the first place) requires gcc to be called via cc. If I could only have it my way all the time . . .
Thanks again.