In centos,how to switch to default gcc after switched to a higher version of gcc with devtoolset











up vote
0
down vote

favorite
1












I want to install several gcc with different versions in centos. The default version of gcc in centos 6 is 4.9.3. So I use devtoolset install a higher version of gcc. Then I switch to the higher version of gcc by executing "source /opt/rh/devtoolset-5/enable". But now if I want to switch back to the default gcc, how should I do?
By the way, is there any solution to install multiple gcc with different versions in centos 5?










share|improve this question


























    up vote
    0
    down vote

    favorite
    1












    I want to install several gcc with different versions in centos. The default version of gcc in centos 6 is 4.9.3. So I use devtoolset install a higher version of gcc. Then I switch to the higher version of gcc by executing "source /opt/rh/devtoolset-5/enable". But now if I want to switch back to the default gcc, how should I do?
    By the way, is there any solution to install multiple gcc with different versions in centos 5?










    share|improve this question
























      up vote
      0
      down vote

      favorite
      1









      up vote
      0
      down vote

      favorite
      1






      1





      I want to install several gcc with different versions in centos. The default version of gcc in centos 6 is 4.9.3. So I use devtoolset install a higher version of gcc. Then I switch to the higher version of gcc by executing "source /opt/rh/devtoolset-5/enable". But now if I want to switch back to the default gcc, how should I do?
      By the way, is there any solution to install multiple gcc with different versions in centos 5?










      share|improve this question













      I want to install several gcc with different versions in centos. The default version of gcc in centos 6 is 4.9.3. So I use devtoolset install a higher version of gcc. Then I switch to the higher version of gcc by executing "source /opt/rh/devtoolset-5/enable". But now if I want to switch back to the default gcc, how should I do?
      By the way, is there any solution to install multiple gcc with different versions in centos 5?







      centos gcc






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 1 at 3:04









      yifan

      31




      31






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The version of gcc that's distributed with CentOS 6 is actually 4.4.7.



          You can install as many versions of gcc either by installing devtoolset-# via yum or by compiling then from source.



          The first way is the easiest. Make sure that you are installing the devtoolset packages via the scl repo. I figure that you already did as you have installed one already but in case you didn't:



          yum install centos-release-scl


          You can then use the below command to set the gcc version to whichever one you want. Using 5 for this example and assuming that your shell is bash:



          scl enable devtoolset-5 bash


          If you want to change to 6:



          scl enable devtoolset-6 bash


          If you want to change back to the default then any of the following will work assuming bash is your shell:



          bash



          source ~/.bash_profile



          The first will start a new shell session and set any aliases/variables/commands in ~/.bashrc. The second will set it with the variables/commands in ~/.bash_profile. (Without the devtoolset enabled).



          You can even put scl enable devtoolset-5 bash, for example, in ~/.bashrc or ~/.bash_profile so that it sets the gcc version to one of the devtoolset versions at login. To go back to the system default if you use this method, comment the line out in ~/.bashrc or ~/.bash_profile and then run bash or source ~/.bash_profile, respectively. That will start a new shell session with everything in one of those shell init files except the scl enable command that you commented out. The only downside is that any variables that you've set via the export command will no longer be there as the shell session will be new.






          share|improve this answer






























            up vote
            0
            down vote













            It's probably just a matter of changing some environment variables,
            like PATH
            How big is that ⁠/opt/rh/devtoolset-5/enable file? 
            Can you look at it, see what it does,
            and adapt it for the older compiler that you want to use? 
            The obvious things to look for would be the names of the directories
            where the new compiler's files are installed
            (change them to the corresponding pathnames for the old compiler)
            and the version number. 
            I don't know what else is likely to be there.






            share|improve this answer























            • I've updated the answer with some fairly obvious thoughts.  If you can't see what needs to be changed, I probably won't be able to do much better. I've never heard of devtoolset; you may need to wait for an expert in that product to answer.
              – Scott
              Dec 1 at 3:37











            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485284%2fin-centos-how-to-switch-to-default-gcc-after-switched-to-a-higher-version-of-gcc%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            The version of gcc that's distributed with CentOS 6 is actually 4.4.7.



            You can install as many versions of gcc either by installing devtoolset-# via yum or by compiling then from source.



            The first way is the easiest. Make sure that you are installing the devtoolset packages via the scl repo. I figure that you already did as you have installed one already but in case you didn't:



            yum install centos-release-scl


            You can then use the below command to set the gcc version to whichever one you want. Using 5 for this example and assuming that your shell is bash:



            scl enable devtoolset-5 bash


            If you want to change to 6:



            scl enable devtoolset-6 bash


            If you want to change back to the default then any of the following will work assuming bash is your shell:



            bash



            source ~/.bash_profile



            The first will start a new shell session and set any aliases/variables/commands in ~/.bashrc. The second will set it with the variables/commands in ~/.bash_profile. (Without the devtoolset enabled).



            You can even put scl enable devtoolset-5 bash, for example, in ~/.bashrc or ~/.bash_profile so that it sets the gcc version to one of the devtoolset versions at login. To go back to the system default if you use this method, comment the line out in ~/.bashrc or ~/.bash_profile and then run bash or source ~/.bash_profile, respectively. That will start a new shell session with everything in one of those shell init files except the scl enable command that you commented out. The only downside is that any variables that you've set via the export command will no longer be there as the shell session will be new.






            share|improve this answer



























              up vote
              1
              down vote



              accepted










              The version of gcc that's distributed with CentOS 6 is actually 4.4.7.



              You can install as many versions of gcc either by installing devtoolset-# via yum or by compiling then from source.



              The first way is the easiest. Make sure that you are installing the devtoolset packages via the scl repo. I figure that you already did as you have installed one already but in case you didn't:



              yum install centos-release-scl


              You can then use the below command to set the gcc version to whichever one you want. Using 5 for this example and assuming that your shell is bash:



              scl enable devtoolset-5 bash


              If you want to change to 6:



              scl enable devtoolset-6 bash


              If you want to change back to the default then any of the following will work assuming bash is your shell:



              bash



              source ~/.bash_profile



              The first will start a new shell session and set any aliases/variables/commands in ~/.bashrc. The second will set it with the variables/commands in ~/.bash_profile. (Without the devtoolset enabled).



              You can even put scl enable devtoolset-5 bash, for example, in ~/.bashrc or ~/.bash_profile so that it sets the gcc version to one of the devtoolset versions at login. To go back to the system default if you use this method, comment the line out in ~/.bashrc or ~/.bash_profile and then run bash or source ~/.bash_profile, respectively. That will start a new shell session with everything in one of those shell init files except the scl enable command that you commented out. The only downside is that any variables that you've set via the export command will no longer be there as the shell session will be new.






              share|improve this answer

























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                The version of gcc that's distributed with CentOS 6 is actually 4.4.7.



                You can install as many versions of gcc either by installing devtoolset-# via yum or by compiling then from source.



                The first way is the easiest. Make sure that you are installing the devtoolset packages via the scl repo. I figure that you already did as you have installed one already but in case you didn't:



                yum install centos-release-scl


                You can then use the below command to set the gcc version to whichever one you want. Using 5 for this example and assuming that your shell is bash:



                scl enable devtoolset-5 bash


                If you want to change to 6:



                scl enable devtoolset-6 bash


                If you want to change back to the default then any of the following will work assuming bash is your shell:



                bash



                source ~/.bash_profile



                The first will start a new shell session and set any aliases/variables/commands in ~/.bashrc. The second will set it with the variables/commands in ~/.bash_profile. (Without the devtoolset enabled).



                You can even put scl enable devtoolset-5 bash, for example, in ~/.bashrc or ~/.bash_profile so that it sets the gcc version to one of the devtoolset versions at login. To go back to the system default if you use this method, comment the line out in ~/.bashrc or ~/.bash_profile and then run bash or source ~/.bash_profile, respectively. That will start a new shell session with everything in one of those shell init files except the scl enable command that you commented out. The only downside is that any variables that you've set via the export command will no longer be there as the shell session will be new.






                share|improve this answer














                The version of gcc that's distributed with CentOS 6 is actually 4.4.7.



                You can install as many versions of gcc either by installing devtoolset-# via yum or by compiling then from source.



                The first way is the easiest. Make sure that you are installing the devtoolset packages via the scl repo. I figure that you already did as you have installed one already but in case you didn't:



                yum install centos-release-scl


                You can then use the below command to set the gcc version to whichever one you want. Using 5 for this example and assuming that your shell is bash:



                scl enable devtoolset-5 bash


                If you want to change to 6:



                scl enable devtoolset-6 bash


                If you want to change back to the default then any of the following will work assuming bash is your shell:



                bash



                source ~/.bash_profile



                The first will start a new shell session and set any aliases/variables/commands in ~/.bashrc. The second will set it with the variables/commands in ~/.bash_profile. (Without the devtoolset enabled).



                You can even put scl enable devtoolset-5 bash, for example, in ~/.bashrc or ~/.bash_profile so that it sets the gcc version to one of the devtoolset versions at login. To go back to the system default if you use this method, comment the line out in ~/.bashrc or ~/.bash_profile and then run bash or source ~/.bash_profile, respectively. That will start a new shell session with everything in one of those shell init files except the scl enable command that you commented out. The only downside is that any variables that you've set via the export command will no longer be there as the shell session will be new.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 1 at 4:19

























                answered Dec 1 at 3:56









                Nasir Riley

                2,231239




                2,231239
























                    up vote
                    0
                    down vote













                    It's probably just a matter of changing some environment variables,
                    like PATH
                    How big is that ⁠/opt/rh/devtoolset-5/enable file? 
                    Can you look at it, see what it does,
                    and adapt it for the older compiler that you want to use? 
                    The obvious things to look for would be the names of the directories
                    where the new compiler's files are installed
                    (change them to the corresponding pathnames for the old compiler)
                    and the version number. 
                    I don't know what else is likely to be there.






                    share|improve this answer























                    • I've updated the answer with some fairly obvious thoughts.  If you can't see what needs to be changed, I probably won't be able to do much better. I've never heard of devtoolset; you may need to wait for an expert in that product to answer.
                      – Scott
                      Dec 1 at 3:37















                    up vote
                    0
                    down vote













                    It's probably just a matter of changing some environment variables,
                    like PATH
                    How big is that ⁠/opt/rh/devtoolset-5/enable file? 
                    Can you look at it, see what it does,
                    and adapt it for the older compiler that you want to use? 
                    The obvious things to look for would be the names of the directories
                    where the new compiler's files are installed
                    (change them to the corresponding pathnames for the old compiler)
                    and the version number. 
                    I don't know what else is likely to be there.






                    share|improve this answer























                    • I've updated the answer with some fairly obvious thoughts.  If you can't see what needs to be changed, I probably won't be able to do much better. I've never heard of devtoolset; you may need to wait for an expert in that product to answer.
                      – Scott
                      Dec 1 at 3:37













                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    It's probably just a matter of changing some environment variables,
                    like PATH
                    How big is that ⁠/opt/rh/devtoolset-5/enable file? 
                    Can you look at it, see what it does,
                    and adapt it for the older compiler that you want to use? 
                    The obvious things to look for would be the names of the directories
                    where the new compiler's files are installed
                    (change them to the corresponding pathnames for the old compiler)
                    and the version number. 
                    I don't know what else is likely to be there.






                    share|improve this answer














                    It's probably just a matter of changing some environment variables,
                    like PATH
                    How big is that ⁠/opt/rh/devtoolset-5/enable file? 
                    Can you look at it, see what it does,
                    and adapt it for the older compiler that you want to use? 
                    The obvious things to look for would be the names of the directories
                    where the new compiler's files are installed
                    (change them to the corresponding pathnames for the old compiler)
                    and the version number. 
                    I don't know what else is likely to be there.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Dec 1 at 3:37

























                    answered Dec 1 at 3:14









                    Scott

                    6,77742650




                    6,77742650












                    • I've updated the answer with some fairly obvious thoughts.  If you can't see what needs to be changed, I probably won't be able to do much better. I've never heard of devtoolset; you may need to wait for an expert in that product to answer.
                      – Scott
                      Dec 1 at 3:37


















                    • I've updated the answer with some fairly obvious thoughts.  If you can't see what needs to be changed, I probably won't be able to do much better. I've never heard of devtoolset; you may need to wait for an expert in that product to answer.
                      – Scott
                      Dec 1 at 3:37
















                    I've updated the answer with some fairly obvious thoughts.  If you can't see what needs to be changed, I probably won't be able to do much better. I've never heard of devtoolset; you may need to wait for an expert in that product to answer.
                    – Scott
                    Dec 1 at 3:37




                    I've updated the answer with some fairly obvious thoughts.  If you can't see what needs to be changed, I probably won't be able to do much better. I've never heard of devtoolset; you may need to wait for an expert in that product to answer.
                    – Scott
                    Dec 1 at 3:37


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485284%2fin-centos-how-to-switch-to-default-gcc-after-switched-to-a-higher-version-of-gcc%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Morgemoulin

                    Scott Moir

                    Souastre