How to install GCC 5 on debian jessie 8.1












19















I tried many solutions to install update for my gcc compiler on debian server. None of them worked. I need the compiler update to use new features of c++11, as this provides a stable libcxx11 ABI, and stable support for C++11 (refer here). Specifically getting version `GLIBCXX_3.4.21' which is not included in my current compiler gcc version 4.9.2 (Debian 4.9.2-10).



Some pointers to solution will be helpful. Thanks in advance.



Some links to forum related to my issue which I already tried:



1
2
3 (not entirely related solution is for ubuntu, but I couldn't find gcc-5 in ftp server of debian yet)










share|improve this question

























  • That's provided in Debian/testing, and as you see, involves changes to the runtime libraries. Someone might advise you how to do this as a Debian package, but the effect would be little different from switching to the testing configuration due to the large number of affected packages.

    – Thomas Dickey
    May 22 '16 at 20:41











  • Why do you specifically need the new ABI support? You can build most C++11 code with Debian 8's gcc 4.9.2, you'll just need to recompile it when Debian 9 is released. If you can't wait, the easiest solution would be to switch to testing, but that's probably not a good idea on a server (depending on what you mean by server of course). The switch from gcc 4.9 to gcc 5 involved a library transition, so you're in for a world of pain if you try to do it yourself!

    – Stephen Kitt
    May 22 '16 at 21:20











  • I agree with what thomas and stephen say, except I am far less worried about the idea of using testing on a server. Not all servers require long-term sameness of binaries and libraries (which is what "stable" means in debian context), for some servers tracking testing or even unstable is more useful (if, say, bleeding-edge features are needed, or just to keep ahead of the script kiddies). However, running testing/unstable on production servers absolutely requires a lot of skill with and knowledge about Debian to fix the occasional breakage. Test upgrades on other machines or VMs first.

    – cas
    May 23 '16 at 1:41











  • @cas I wasn't thinking of the stability of binaries, but rather the two main disadvantages of testing (used on its own): packages are sometimes temporarily removed (so the setup you just validated in your test VM may no longer be available easily), and security fixes can be delayed (sometimes for a long time if testing is undergoing a big library transition, although there is testing-security for such cases).

    – Stephen Kitt
    May 23 '16 at 4:43






  • 1





    If you recompile your program on the Debian system (instead of copying it over) it should work fine.

    – Stephen Kitt
    May 24 '16 at 6:07
















19















I tried many solutions to install update for my gcc compiler on debian server. None of them worked. I need the compiler update to use new features of c++11, as this provides a stable libcxx11 ABI, and stable support for C++11 (refer here). Specifically getting version `GLIBCXX_3.4.21' which is not included in my current compiler gcc version 4.9.2 (Debian 4.9.2-10).



Some pointers to solution will be helpful. Thanks in advance.



Some links to forum related to my issue which I already tried:



1
2
3 (not entirely related solution is for ubuntu, but I couldn't find gcc-5 in ftp server of debian yet)










share|improve this question

























  • That's provided in Debian/testing, and as you see, involves changes to the runtime libraries. Someone might advise you how to do this as a Debian package, but the effect would be little different from switching to the testing configuration due to the large number of affected packages.

    – Thomas Dickey
    May 22 '16 at 20:41











  • Why do you specifically need the new ABI support? You can build most C++11 code with Debian 8's gcc 4.9.2, you'll just need to recompile it when Debian 9 is released. If you can't wait, the easiest solution would be to switch to testing, but that's probably not a good idea on a server (depending on what you mean by server of course). The switch from gcc 4.9 to gcc 5 involved a library transition, so you're in for a world of pain if you try to do it yourself!

    – Stephen Kitt
    May 22 '16 at 21:20











  • I agree with what thomas and stephen say, except I am far less worried about the idea of using testing on a server. Not all servers require long-term sameness of binaries and libraries (which is what "stable" means in debian context), for some servers tracking testing or even unstable is more useful (if, say, bleeding-edge features are needed, or just to keep ahead of the script kiddies). However, running testing/unstable on production servers absolutely requires a lot of skill with and knowledge about Debian to fix the occasional breakage. Test upgrades on other machines or VMs first.

    – cas
    May 23 '16 at 1:41











  • @cas I wasn't thinking of the stability of binaries, but rather the two main disadvantages of testing (used on its own): packages are sometimes temporarily removed (so the setup you just validated in your test VM may no longer be available easily), and security fixes can be delayed (sometimes for a long time if testing is undergoing a big library transition, although there is testing-security for such cases).

    – Stephen Kitt
    May 23 '16 at 4:43






  • 1





    If you recompile your program on the Debian system (instead of copying it over) it should work fine.

    – Stephen Kitt
    May 24 '16 at 6:07














19












19








19


4






I tried many solutions to install update for my gcc compiler on debian server. None of them worked. I need the compiler update to use new features of c++11, as this provides a stable libcxx11 ABI, and stable support for C++11 (refer here). Specifically getting version `GLIBCXX_3.4.21' which is not included in my current compiler gcc version 4.9.2 (Debian 4.9.2-10).



Some pointers to solution will be helpful. Thanks in advance.



Some links to forum related to my issue which I already tried:



1
2
3 (not entirely related solution is for ubuntu, but I couldn't find gcc-5 in ftp server of debian yet)










share|improve this question
















I tried many solutions to install update for my gcc compiler on debian server. None of them worked. I need the compiler update to use new features of c++11, as this provides a stable libcxx11 ABI, and stable support for C++11 (refer here). Specifically getting version `GLIBCXX_3.4.21' which is not included in my current compiler gcc version 4.9.2 (Debian 4.9.2-10).



Some pointers to solution will be helpful. Thanks in advance.



Some links to forum related to my issue which I already tried:



1
2
3 (not entirely related solution is for ubuntu, but I couldn't find gcc-5 in ftp server of debian yet)







debian gcc c++ g++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 21 '17 at 15:35







mluthra

















asked May 22 '16 at 20:15









mluthramluthra

96114




96114













  • That's provided in Debian/testing, and as you see, involves changes to the runtime libraries. Someone might advise you how to do this as a Debian package, but the effect would be little different from switching to the testing configuration due to the large number of affected packages.

    – Thomas Dickey
    May 22 '16 at 20:41











  • Why do you specifically need the new ABI support? You can build most C++11 code with Debian 8's gcc 4.9.2, you'll just need to recompile it when Debian 9 is released. If you can't wait, the easiest solution would be to switch to testing, but that's probably not a good idea on a server (depending on what you mean by server of course). The switch from gcc 4.9 to gcc 5 involved a library transition, so you're in for a world of pain if you try to do it yourself!

    – Stephen Kitt
    May 22 '16 at 21:20











  • I agree with what thomas and stephen say, except I am far less worried about the idea of using testing on a server. Not all servers require long-term sameness of binaries and libraries (which is what "stable" means in debian context), for some servers tracking testing or even unstable is more useful (if, say, bleeding-edge features are needed, or just to keep ahead of the script kiddies). However, running testing/unstable on production servers absolutely requires a lot of skill with and knowledge about Debian to fix the occasional breakage. Test upgrades on other machines or VMs first.

    – cas
    May 23 '16 at 1:41











  • @cas I wasn't thinking of the stability of binaries, but rather the two main disadvantages of testing (used on its own): packages are sometimes temporarily removed (so the setup you just validated in your test VM may no longer be available easily), and security fixes can be delayed (sometimes for a long time if testing is undergoing a big library transition, although there is testing-security for such cases).

    – Stephen Kitt
    May 23 '16 at 4:43






  • 1





    If you recompile your program on the Debian system (instead of copying it over) it should work fine.

    – Stephen Kitt
    May 24 '16 at 6:07



















  • That's provided in Debian/testing, and as you see, involves changes to the runtime libraries. Someone might advise you how to do this as a Debian package, but the effect would be little different from switching to the testing configuration due to the large number of affected packages.

    – Thomas Dickey
    May 22 '16 at 20:41











  • Why do you specifically need the new ABI support? You can build most C++11 code with Debian 8's gcc 4.9.2, you'll just need to recompile it when Debian 9 is released. If you can't wait, the easiest solution would be to switch to testing, but that's probably not a good idea on a server (depending on what you mean by server of course). The switch from gcc 4.9 to gcc 5 involved a library transition, so you're in for a world of pain if you try to do it yourself!

    – Stephen Kitt
    May 22 '16 at 21:20











  • I agree with what thomas and stephen say, except I am far less worried about the idea of using testing on a server. Not all servers require long-term sameness of binaries and libraries (which is what "stable" means in debian context), for some servers tracking testing or even unstable is more useful (if, say, bleeding-edge features are needed, or just to keep ahead of the script kiddies). However, running testing/unstable on production servers absolutely requires a lot of skill with and knowledge about Debian to fix the occasional breakage. Test upgrades on other machines or VMs first.

    – cas
    May 23 '16 at 1:41











  • @cas I wasn't thinking of the stability of binaries, but rather the two main disadvantages of testing (used on its own): packages are sometimes temporarily removed (so the setup you just validated in your test VM may no longer be available easily), and security fixes can be delayed (sometimes for a long time if testing is undergoing a big library transition, although there is testing-security for such cases).

    – Stephen Kitt
    May 23 '16 at 4:43






  • 1





    If you recompile your program on the Debian system (instead of copying it over) it should work fine.

    – Stephen Kitt
    May 24 '16 at 6:07

















That's provided in Debian/testing, and as you see, involves changes to the runtime libraries. Someone might advise you how to do this as a Debian package, but the effect would be little different from switching to the testing configuration due to the large number of affected packages.

– Thomas Dickey
May 22 '16 at 20:41





That's provided in Debian/testing, and as you see, involves changes to the runtime libraries. Someone might advise you how to do this as a Debian package, but the effect would be little different from switching to the testing configuration due to the large number of affected packages.

– Thomas Dickey
May 22 '16 at 20:41













Why do you specifically need the new ABI support? You can build most C++11 code with Debian 8's gcc 4.9.2, you'll just need to recompile it when Debian 9 is released. If you can't wait, the easiest solution would be to switch to testing, but that's probably not a good idea on a server (depending on what you mean by server of course). The switch from gcc 4.9 to gcc 5 involved a library transition, so you're in for a world of pain if you try to do it yourself!

– Stephen Kitt
May 22 '16 at 21:20





Why do you specifically need the new ABI support? You can build most C++11 code with Debian 8's gcc 4.9.2, you'll just need to recompile it when Debian 9 is released. If you can't wait, the easiest solution would be to switch to testing, but that's probably not a good idea on a server (depending on what you mean by server of course). The switch from gcc 4.9 to gcc 5 involved a library transition, so you're in for a world of pain if you try to do it yourself!

– Stephen Kitt
May 22 '16 at 21:20













I agree with what thomas and stephen say, except I am far less worried about the idea of using testing on a server. Not all servers require long-term sameness of binaries and libraries (which is what "stable" means in debian context), for some servers tracking testing or even unstable is more useful (if, say, bleeding-edge features are needed, or just to keep ahead of the script kiddies). However, running testing/unstable on production servers absolutely requires a lot of skill with and knowledge about Debian to fix the occasional breakage. Test upgrades on other machines or VMs first.

– cas
May 23 '16 at 1:41





I agree with what thomas and stephen say, except I am far less worried about the idea of using testing on a server. Not all servers require long-term sameness of binaries and libraries (which is what "stable" means in debian context), for some servers tracking testing or even unstable is more useful (if, say, bleeding-edge features are needed, or just to keep ahead of the script kiddies). However, running testing/unstable on production servers absolutely requires a lot of skill with and knowledge about Debian to fix the occasional breakage. Test upgrades on other machines or VMs first.

– cas
May 23 '16 at 1:41













@cas I wasn't thinking of the stability of binaries, but rather the two main disadvantages of testing (used on its own): packages are sometimes temporarily removed (so the setup you just validated in your test VM may no longer be available easily), and security fixes can be delayed (sometimes for a long time if testing is undergoing a big library transition, although there is testing-security for such cases).

– Stephen Kitt
May 23 '16 at 4:43





@cas I wasn't thinking of the stability of binaries, but rather the two main disadvantages of testing (used on its own): packages are sometimes temporarily removed (so the setup you just validated in your test VM may no longer be available easily), and security fixes can be delayed (sometimes for a long time if testing is undergoing a big library transition, although there is testing-security for such cases).

– Stephen Kitt
May 23 '16 at 4:43




1




1





If you recompile your program on the Debian system (instead of copying it over) it should work fine.

– Stephen Kitt
May 24 '16 at 6:07





If you recompile your program on the Debian system (instead of copying it over) it should work fine.

– Stephen Kitt
May 24 '16 at 6:07










4 Answers
4






active

oldest

votes


















11














I needed GCC 5+ installed on debian jessie and, as is available for debian testing (at least on jun-16) you can use apt-pinning to install packages available there (see https://wiki.debian.org/AptPreferences).



To install GCC 5+ from testing on debian jessie using apt-pinning:




  1. Add debian testing repo to your apt sources by creating a file on /etc/apt/sources.list.d folder containing the line deb http://ftp.us.debian.org/debian testing main contrib non-free



  2. Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:



    Package: *
    Pin: release a=testing
    Pin-Priority: 100



  3. Update apt database: sudo apt-get update



  4. Install gcc from testing: sudo apt-get install -t testing gcc



    Note that using -t testing you tell apt-get to install gcc from testing sources as configured earlier.




I strongly suggest to clean any compilation and re-compile any dependency before compiling your sources again.



Have fun!






share|improve this answer





















  • 1





    I have never tried this (nor do I wish to try it), but your procedure is interesting. Not many software suites are as tightly bound up with, and woven through, the entire Debian system as GCC. Does your procedure really work? Or does it cause more problems than it solves? Curious.

    – thb
    Sep 12 '16 at 0:35








  • 1





    I actually tried it with good results: I could successfully compile what I was building and the system continued to work with no problems.Nevertheless you might be right: changing the GCC version could break compiling other packages (ie compiling sources when installing packages with pip), but I think that this procedure is the least invasive because apt would keep track of which packages depends on GCC and will install compatible versions as needed (as far as I can remember).

    – llekn
    Sep 12 '16 at 20:27








  • 2





    Note for step 2: The file in /etc/apt/preferences.d/ should either not contain a dot "." in the file name, or end in ".pref". Otherwise, this file is ignored. An explanation of the meaning of value 100 and why it was chosen would be appreciated.

    – Ludwig Schulze
    Nov 22 '16 at 15:37













  • As I understand, the more Pin-Priority a package gets, the more preference it will get over other packages with a lower number. So, as in Debian's AptPrefences page states, testing by default gets Pin-Priority: 900 making all packages from testing to be installed by default. So, specifying that testing will have a Pin-Priority: 100 lowers testing packages priority making them installable only if requested when specifying the target at apt-get install -t testing ...

    – llekn
    Feb 2 '17 at 16:01








  • 1





    @LeeK-B Indeed, using Package: gcc upgrades the entire system to testing. The documentation about apt-prefences is confusing so I suppose this is what is happening: 1: As packages from testing have greater versions, by default they have precedence over standard ones 2: Specifying Package: gcc with Pin-priority: 100 makes all packages from testing to have default priority (higher than standard) except gcc. Exactly the opposite that we wanted. I updated the answer to avoid this mistake

    – llekn
    Mar 6 '17 at 15:47





















5














To combine the 2 previous answers into one that works:



echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
apt-get update
apt-get install -t unstable gcc-5


BUT!!! Use this at your own risk as you are installing packages from unstable. You might also want to remove /etc/apt/sources.list.d/unstable.list once you have installed the packages.



If possible, install under Docker so you don't mess up your OS. Your mileage may vary.






share|improve this answer

































    3














    As of 2017-02-19, gcc-5 has been removed from testing:



    https://tracker.debian.org/pkg/gcc-5



    You can apt-get install gcc-5 if you first execute this line as root:



    echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" > /etc/apt/sources.list.d/unstable.list


    Then, you will probably want to change the priority of that source in /etc/apt/preferences.d as per llekn's answer.






    share|improve this answer

































      0














      I was having problems last week; it looks like as of 2019-01-23 gcc-5 has been removed from the repositories completely. (See https://tracker.debian.org/pkg/gcc-5)



      If you really need it I suppose you could compile it from source. I am going to find a way to drop the dependency from my system.






      share|improve this answer























        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',
        autoActivateHeartbeat: false,
        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%2f284817%2fhow-to-install-gcc-5-on-debian-jessie-8-1%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        11














        I needed GCC 5+ installed on debian jessie and, as is available for debian testing (at least on jun-16) you can use apt-pinning to install packages available there (see https://wiki.debian.org/AptPreferences).



        To install GCC 5+ from testing on debian jessie using apt-pinning:




        1. Add debian testing repo to your apt sources by creating a file on /etc/apt/sources.list.d folder containing the line deb http://ftp.us.debian.org/debian testing main contrib non-free



        2. Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:



          Package: *
          Pin: release a=testing
          Pin-Priority: 100



        3. Update apt database: sudo apt-get update



        4. Install gcc from testing: sudo apt-get install -t testing gcc



          Note that using -t testing you tell apt-get to install gcc from testing sources as configured earlier.




        I strongly suggest to clean any compilation and re-compile any dependency before compiling your sources again.



        Have fun!






        share|improve this answer





















        • 1





          I have never tried this (nor do I wish to try it), but your procedure is interesting. Not many software suites are as tightly bound up with, and woven through, the entire Debian system as GCC. Does your procedure really work? Or does it cause more problems than it solves? Curious.

          – thb
          Sep 12 '16 at 0:35








        • 1





          I actually tried it with good results: I could successfully compile what I was building and the system continued to work with no problems.Nevertheless you might be right: changing the GCC version could break compiling other packages (ie compiling sources when installing packages with pip), but I think that this procedure is the least invasive because apt would keep track of which packages depends on GCC and will install compatible versions as needed (as far as I can remember).

          – llekn
          Sep 12 '16 at 20:27








        • 2





          Note for step 2: The file in /etc/apt/preferences.d/ should either not contain a dot "." in the file name, or end in ".pref". Otherwise, this file is ignored. An explanation of the meaning of value 100 and why it was chosen would be appreciated.

          – Ludwig Schulze
          Nov 22 '16 at 15:37













        • As I understand, the more Pin-Priority a package gets, the more preference it will get over other packages with a lower number. So, as in Debian's AptPrefences page states, testing by default gets Pin-Priority: 900 making all packages from testing to be installed by default. So, specifying that testing will have a Pin-Priority: 100 lowers testing packages priority making them installable only if requested when specifying the target at apt-get install -t testing ...

          – llekn
          Feb 2 '17 at 16:01








        • 1





          @LeeK-B Indeed, using Package: gcc upgrades the entire system to testing. The documentation about apt-prefences is confusing so I suppose this is what is happening: 1: As packages from testing have greater versions, by default they have precedence over standard ones 2: Specifying Package: gcc with Pin-priority: 100 makes all packages from testing to have default priority (higher than standard) except gcc. Exactly the opposite that we wanted. I updated the answer to avoid this mistake

          – llekn
          Mar 6 '17 at 15:47


















        11














        I needed GCC 5+ installed on debian jessie and, as is available for debian testing (at least on jun-16) you can use apt-pinning to install packages available there (see https://wiki.debian.org/AptPreferences).



        To install GCC 5+ from testing on debian jessie using apt-pinning:




        1. Add debian testing repo to your apt sources by creating a file on /etc/apt/sources.list.d folder containing the line deb http://ftp.us.debian.org/debian testing main contrib non-free



        2. Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:



          Package: *
          Pin: release a=testing
          Pin-Priority: 100



        3. Update apt database: sudo apt-get update



        4. Install gcc from testing: sudo apt-get install -t testing gcc



          Note that using -t testing you tell apt-get to install gcc from testing sources as configured earlier.




        I strongly suggest to clean any compilation and re-compile any dependency before compiling your sources again.



        Have fun!






        share|improve this answer





















        • 1





          I have never tried this (nor do I wish to try it), but your procedure is interesting. Not many software suites are as tightly bound up with, and woven through, the entire Debian system as GCC. Does your procedure really work? Or does it cause more problems than it solves? Curious.

          – thb
          Sep 12 '16 at 0:35








        • 1





          I actually tried it with good results: I could successfully compile what I was building and the system continued to work with no problems.Nevertheless you might be right: changing the GCC version could break compiling other packages (ie compiling sources when installing packages with pip), but I think that this procedure is the least invasive because apt would keep track of which packages depends on GCC and will install compatible versions as needed (as far as I can remember).

          – llekn
          Sep 12 '16 at 20:27








        • 2





          Note for step 2: The file in /etc/apt/preferences.d/ should either not contain a dot "." in the file name, or end in ".pref". Otherwise, this file is ignored. An explanation of the meaning of value 100 and why it was chosen would be appreciated.

          – Ludwig Schulze
          Nov 22 '16 at 15:37













        • As I understand, the more Pin-Priority a package gets, the more preference it will get over other packages with a lower number. So, as in Debian's AptPrefences page states, testing by default gets Pin-Priority: 900 making all packages from testing to be installed by default. So, specifying that testing will have a Pin-Priority: 100 lowers testing packages priority making them installable only if requested when specifying the target at apt-get install -t testing ...

          – llekn
          Feb 2 '17 at 16:01








        • 1





          @LeeK-B Indeed, using Package: gcc upgrades the entire system to testing. The documentation about apt-prefences is confusing so I suppose this is what is happening: 1: As packages from testing have greater versions, by default they have precedence over standard ones 2: Specifying Package: gcc with Pin-priority: 100 makes all packages from testing to have default priority (higher than standard) except gcc. Exactly the opposite that we wanted. I updated the answer to avoid this mistake

          – llekn
          Mar 6 '17 at 15:47
















        11












        11








        11







        I needed GCC 5+ installed on debian jessie and, as is available for debian testing (at least on jun-16) you can use apt-pinning to install packages available there (see https://wiki.debian.org/AptPreferences).



        To install GCC 5+ from testing on debian jessie using apt-pinning:




        1. Add debian testing repo to your apt sources by creating a file on /etc/apt/sources.list.d folder containing the line deb http://ftp.us.debian.org/debian testing main contrib non-free



        2. Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:



          Package: *
          Pin: release a=testing
          Pin-Priority: 100



        3. Update apt database: sudo apt-get update



        4. Install gcc from testing: sudo apt-get install -t testing gcc



          Note that using -t testing you tell apt-get to install gcc from testing sources as configured earlier.




        I strongly suggest to clean any compilation and re-compile any dependency before compiling your sources again.



        Have fun!






        share|improve this answer















        I needed GCC 5+ installed on debian jessie and, as is available for debian testing (at least on jun-16) you can use apt-pinning to install packages available there (see https://wiki.debian.org/AptPreferences).



        To install GCC 5+ from testing on debian jessie using apt-pinning:




        1. Add debian testing repo to your apt sources by creating a file on /etc/apt/sources.list.d folder containing the line deb http://ftp.us.debian.org/debian testing main contrib non-free



        2. Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:



          Package: *
          Pin: release a=testing
          Pin-Priority: 100



        3. Update apt database: sudo apt-get update



        4. Install gcc from testing: sudo apt-get install -t testing gcc



          Note that using -t testing you tell apt-get to install gcc from testing sources as configured earlier.




        I strongly suggest to clean any compilation and re-compile any dependency before compiling your sources again.



        Have fun!







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 6 '17 at 15:49

























        answered Jun 15 '16 at 21:13









        lleknllekn

        21114




        21114








        • 1





          I have never tried this (nor do I wish to try it), but your procedure is interesting. Not many software suites are as tightly bound up with, and woven through, the entire Debian system as GCC. Does your procedure really work? Or does it cause more problems than it solves? Curious.

          – thb
          Sep 12 '16 at 0:35








        • 1





          I actually tried it with good results: I could successfully compile what I was building and the system continued to work with no problems.Nevertheless you might be right: changing the GCC version could break compiling other packages (ie compiling sources when installing packages with pip), but I think that this procedure is the least invasive because apt would keep track of which packages depends on GCC and will install compatible versions as needed (as far as I can remember).

          – llekn
          Sep 12 '16 at 20:27








        • 2





          Note for step 2: The file in /etc/apt/preferences.d/ should either not contain a dot "." in the file name, or end in ".pref". Otherwise, this file is ignored. An explanation of the meaning of value 100 and why it was chosen would be appreciated.

          – Ludwig Schulze
          Nov 22 '16 at 15:37













        • As I understand, the more Pin-Priority a package gets, the more preference it will get over other packages with a lower number. So, as in Debian's AptPrefences page states, testing by default gets Pin-Priority: 900 making all packages from testing to be installed by default. So, specifying that testing will have a Pin-Priority: 100 lowers testing packages priority making them installable only if requested when specifying the target at apt-get install -t testing ...

          – llekn
          Feb 2 '17 at 16:01








        • 1





          @LeeK-B Indeed, using Package: gcc upgrades the entire system to testing. The documentation about apt-prefences is confusing so I suppose this is what is happening: 1: As packages from testing have greater versions, by default they have precedence over standard ones 2: Specifying Package: gcc with Pin-priority: 100 makes all packages from testing to have default priority (higher than standard) except gcc. Exactly the opposite that we wanted. I updated the answer to avoid this mistake

          – llekn
          Mar 6 '17 at 15:47
















        • 1





          I have never tried this (nor do I wish to try it), but your procedure is interesting. Not many software suites are as tightly bound up with, and woven through, the entire Debian system as GCC. Does your procedure really work? Or does it cause more problems than it solves? Curious.

          – thb
          Sep 12 '16 at 0:35








        • 1





          I actually tried it with good results: I could successfully compile what I was building and the system continued to work with no problems.Nevertheless you might be right: changing the GCC version could break compiling other packages (ie compiling sources when installing packages with pip), but I think that this procedure is the least invasive because apt would keep track of which packages depends on GCC and will install compatible versions as needed (as far as I can remember).

          – llekn
          Sep 12 '16 at 20:27








        • 2





          Note for step 2: The file in /etc/apt/preferences.d/ should either not contain a dot "." in the file name, or end in ".pref". Otherwise, this file is ignored. An explanation of the meaning of value 100 and why it was chosen would be appreciated.

          – Ludwig Schulze
          Nov 22 '16 at 15:37













        • As I understand, the more Pin-Priority a package gets, the more preference it will get over other packages with a lower number. So, as in Debian's AptPrefences page states, testing by default gets Pin-Priority: 900 making all packages from testing to be installed by default. So, specifying that testing will have a Pin-Priority: 100 lowers testing packages priority making them installable only if requested when specifying the target at apt-get install -t testing ...

          – llekn
          Feb 2 '17 at 16:01








        • 1





          @LeeK-B Indeed, using Package: gcc upgrades the entire system to testing. The documentation about apt-prefences is confusing so I suppose this is what is happening: 1: As packages from testing have greater versions, by default they have precedence over standard ones 2: Specifying Package: gcc with Pin-priority: 100 makes all packages from testing to have default priority (higher than standard) except gcc. Exactly the opposite that we wanted. I updated the answer to avoid this mistake

          – llekn
          Mar 6 '17 at 15:47










        1




        1





        I have never tried this (nor do I wish to try it), but your procedure is interesting. Not many software suites are as tightly bound up with, and woven through, the entire Debian system as GCC. Does your procedure really work? Or does it cause more problems than it solves? Curious.

        – thb
        Sep 12 '16 at 0:35







        I have never tried this (nor do I wish to try it), but your procedure is interesting. Not many software suites are as tightly bound up with, and woven through, the entire Debian system as GCC. Does your procedure really work? Or does it cause more problems than it solves? Curious.

        – thb
        Sep 12 '16 at 0:35






        1




        1





        I actually tried it with good results: I could successfully compile what I was building and the system continued to work with no problems.Nevertheless you might be right: changing the GCC version could break compiling other packages (ie compiling sources when installing packages with pip), but I think that this procedure is the least invasive because apt would keep track of which packages depends on GCC and will install compatible versions as needed (as far as I can remember).

        – llekn
        Sep 12 '16 at 20:27







        I actually tried it with good results: I could successfully compile what I was building and the system continued to work with no problems.Nevertheless you might be right: changing the GCC version could break compiling other packages (ie compiling sources when installing packages with pip), but I think that this procedure is the least invasive because apt would keep track of which packages depends on GCC and will install compatible versions as needed (as far as I can remember).

        – llekn
        Sep 12 '16 at 20:27






        2




        2





        Note for step 2: The file in /etc/apt/preferences.d/ should either not contain a dot "." in the file name, or end in ".pref". Otherwise, this file is ignored. An explanation of the meaning of value 100 and why it was chosen would be appreciated.

        – Ludwig Schulze
        Nov 22 '16 at 15:37







        Note for step 2: The file in /etc/apt/preferences.d/ should either not contain a dot "." in the file name, or end in ".pref". Otherwise, this file is ignored. An explanation of the meaning of value 100 and why it was chosen would be appreciated.

        – Ludwig Schulze
        Nov 22 '16 at 15:37















        As I understand, the more Pin-Priority a package gets, the more preference it will get over other packages with a lower number. So, as in Debian's AptPrefences page states, testing by default gets Pin-Priority: 900 making all packages from testing to be installed by default. So, specifying that testing will have a Pin-Priority: 100 lowers testing packages priority making them installable only if requested when specifying the target at apt-get install -t testing ...

        – llekn
        Feb 2 '17 at 16:01







        As I understand, the more Pin-Priority a package gets, the more preference it will get over other packages with a lower number. So, as in Debian's AptPrefences page states, testing by default gets Pin-Priority: 900 making all packages from testing to be installed by default. So, specifying that testing will have a Pin-Priority: 100 lowers testing packages priority making them installable only if requested when specifying the target at apt-get install -t testing ...

        – llekn
        Feb 2 '17 at 16:01






        1




        1





        @LeeK-B Indeed, using Package: gcc upgrades the entire system to testing. The documentation about apt-prefences is confusing so I suppose this is what is happening: 1: As packages from testing have greater versions, by default they have precedence over standard ones 2: Specifying Package: gcc with Pin-priority: 100 makes all packages from testing to have default priority (higher than standard) except gcc. Exactly the opposite that we wanted. I updated the answer to avoid this mistake

        – llekn
        Mar 6 '17 at 15:47







        @LeeK-B Indeed, using Package: gcc upgrades the entire system to testing. The documentation about apt-prefences is confusing so I suppose this is what is happening: 1: As packages from testing have greater versions, by default they have precedence over standard ones 2: Specifying Package: gcc with Pin-priority: 100 makes all packages from testing to have default priority (higher than standard) except gcc. Exactly the opposite that we wanted. I updated the answer to avoid this mistake

        – llekn
        Mar 6 '17 at 15:47















        5














        To combine the 2 previous answers into one that works:



        echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
        apt-get update
        apt-get install -t unstable gcc-5


        BUT!!! Use this at your own risk as you are installing packages from unstable. You might also want to remove /etc/apt/sources.list.d/unstable.list once you have installed the packages.



        If possible, install under Docker so you don't mess up your OS. Your mileage may vary.






        share|improve this answer






























          5














          To combine the 2 previous answers into one that works:



          echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
          apt-get update
          apt-get install -t unstable gcc-5


          BUT!!! Use this at your own risk as you are installing packages from unstable. You might also want to remove /etc/apt/sources.list.d/unstable.list once you have installed the packages.



          If possible, install under Docker so you don't mess up your OS. Your mileage may vary.






          share|improve this answer




























            5












            5








            5







            To combine the 2 previous answers into one that works:



            echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
            apt-get update
            apt-get install -t unstable gcc-5


            BUT!!! Use this at your own risk as you are installing packages from unstable. You might also want to remove /etc/apt/sources.list.d/unstable.list once you have installed the packages.



            If possible, install under Docker so you don't mess up your OS. Your mileage may vary.






            share|improve this answer















            To combine the 2 previous answers into one that works:



            echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
            apt-get update
            apt-get install -t unstable gcc-5


            BUT!!! Use this at your own risk as you are installing packages from unstable. You might also want to remove /etc/apt/sources.list.d/unstable.list once you have installed the packages.



            If possible, install under Docker so you don't mess up your OS. Your mileage may vary.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 12 '17 at 12:06









            Vadim Kotov

            1258




            1258










            answered Apr 19 '17 at 18:11









            johndodojohndodo

            15613




            15613























                3














                As of 2017-02-19, gcc-5 has been removed from testing:



                https://tracker.debian.org/pkg/gcc-5



                You can apt-get install gcc-5 if you first execute this line as root:



                echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" > /etc/apt/sources.list.d/unstable.list


                Then, you will probably want to change the priority of that source in /etc/apt/preferences.d as per llekn's answer.






                share|improve this answer






























                  3














                  As of 2017-02-19, gcc-5 has been removed from testing:



                  https://tracker.debian.org/pkg/gcc-5



                  You can apt-get install gcc-5 if you first execute this line as root:



                  echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" > /etc/apt/sources.list.d/unstable.list


                  Then, you will probably want to change the priority of that source in /etc/apt/preferences.d as per llekn's answer.






                  share|improve this answer




























                    3












                    3








                    3







                    As of 2017-02-19, gcc-5 has been removed from testing:



                    https://tracker.debian.org/pkg/gcc-5



                    You can apt-get install gcc-5 if you first execute this line as root:



                    echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" > /etc/apt/sources.list.d/unstable.list


                    Then, you will probably want to change the priority of that source in /etc/apt/preferences.d as per llekn's answer.






                    share|improve this answer















                    As of 2017-02-19, gcc-5 has been removed from testing:



                    https://tracker.debian.org/pkg/gcc-5



                    You can apt-get install gcc-5 if you first execute this line as root:



                    echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" > /etc/apt/sources.list.d/unstable.list


                    Then, you will probably want to change the priority of that source in /etc/apt/preferences.d as per llekn's answer.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jun 26 '17 at 10:30









                    Tom Zych

                    779616




                    779616










                    answered Apr 18 '17 at 12:43









                    nachoparkernachoparker

                    47945




                    47945























                        0














                        I was having problems last week; it looks like as of 2019-01-23 gcc-5 has been removed from the repositories completely. (See https://tracker.debian.org/pkg/gcc-5)



                        If you really need it I suppose you could compile it from source. I am going to find a way to drop the dependency from my system.






                        share|improve this answer




























                          0














                          I was having problems last week; it looks like as of 2019-01-23 gcc-5 has been removed from the repositories completely. (See https://tracker.debian.org/pkg/gcc-5)



                          If you really need it I suppose you could compile it from source. I am going to find a way to drop the dependency from my system.






                          share|improve this answer


























                            0












                            0








                            0







                            I was having problems last week; it looks like as of 2019-01-23 gcc-5 has been removed from the repositories completely. (See https://tracker.debian.org/pkg/gcc-5)



                            If you really need it I suppose you could compile it from source. I am going to find a way to drop the dependency from my system.






                            share|improve this answer













                            I was having problems last week; it looks like as of 2019-01-23 gcc-5 has been removed from the repositories completely. (See https://tracker.debian.org/pkg/gcc-5)



                            If you really need it I suppose you could compile it from source. I am going to find a way to drop the dependency from my system.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 28 at 16:36









                            JDongJDong

                            1033




                            1033






























                                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.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f284817%2fhow-to-install-gcc-5-on-debian-jessie-8-1%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

                                How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                                is 'sed' thread safe

                                How to make a Squid Proxy server?