Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I posted this in the newbie forum earlier, but this might be a more appropriate forum for it. I've just installed gcc 3.3.2, but when I do "gcc -v" ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2004
    Posts
    94

    Changing the Default C Compiler


    Hi,

    I posted this in the newbie forum earlier, but this might be a more appropriate forum for it.

    I've just installed gcc 3.3.2, but when I do "gcc -v" I still get "gcc 2.96." How do I set gcc3 as the default C compiler on my system?

    Thanks for your help.

    *****

    I've searched Google quite a bit to find an answer. A long time ago I saw something like "export CC=$CC:/usr/local/bin/gcc3" as a way to export the new compiler as the default, but after I export, I still get "gcc 2.96" when I run "gcc -v."

  2. #2
    Linux Newbie
    Join Date
    May 2004
    Location
    Boston, MA
    Posts
    246
    I think the command /usr/bin/gcc is just a symlink to /usr/bin/gcc-x.xx. I know it is on my system; to see if it is on yours, just use
    Code:
    file /usr/bin/gcc
    If it is a symlink, the output should be something like
    Code:
    /usr/bin/gcc: symbolic link to `/usr/bin/gcc-2.96'
    If this is the case, just change the target of the link with
    Code:
    ln -sf /usr/bin/gcc-3.3.2 /usr/bin/gcc
    Good luck!
    Situations arise because of the weather,
    And no kinds of love are better than others.

  3. #3
    Just Joined!
    Join Date
    Jul 2004
    Posts
    94
    Hi Goran,

    Here's what I get when I do that:

    Code:
    $ file /usr/bin/gcc
    /usr/bin/gcc: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked (uses shared libs), stripped
    $
    So it appears that mine is not a symlink.

    I just have to keep searching for an answer, I guess.

  4. #4
    Linux Newbie
    Join Date
    May 2004
    Location
    Boston, MA
    Posts
    246
    What programs do you have in /usr/bin/ that start with gcc? I.e., what's the output of
    Code:
    find /usr/bin | grep gcc
    If you see both gcc-3.3.2 and gcc-2.96, then maybe your /usr/bin/gcc file is a hard link. Run
    Code:
    stat /usr/bin/gcc
    to find out: if it says Links: 2, then this is probably the case, and you should do as follows (otherwise I'm out of ideas, but maybe someone else on the forum can help):

    Just in case this doesn't work, make a backup copy of /usr/bin/gcc at ~/gcc.backup or something. Then simply remove /usr/bin/gcc and then run
    Code:
    ln -s /usr/bin/gcc-3.3.2 /usr/bin/gcc
    Now the command gcc should point to gcc-3.3.2. If it didn't work, remove the link and copy your backup file back to /usr/bin/gcc. And that's all I can think of.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •