Using C++17 with clang++ on Ubuntu 16.04












1















I can't for the life of me figure out how to get C++17 to work on Ubuntu 16.04.



This works on Ubuntu 18.04:



sudo apt-get update
sudo apt-get install clang-6.0


which installs the C++17 standard library headers in /usr/include/c++/7. However, when I run the same commands in Ubuntu 16.04, I get C++14 headers in /usr/include/c++/5, and C++17 features won't compile.



I tried following this as well to install clang-7, but that led to the following error:
clang: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'GLIBCXX_3.4.22' not found (required by clang)



Apologies if this is a dumb question; I am new to this stuff and am probably missing something obvious.










share|improve this question



























    1















    I can't for the life of me figure out how to get C++17 to work on Ubuntu 16.04.



    This works on Ubuntu 18.04:



    sudo apt-get update
    sudo apt-get install clang-6.0


    which installs the C++17 standard library headers in /usr/include/c++/7. However, when I run the same commands in Ubuntu 16.04, I get C++14 headers in /usr/include/c++/5, and C++17 features won't compile.



    I tried following this as well to install clang-7, but that led to the following error:
    clang: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'GLIBCXX_3.4.22' not found (required by clang)



    Apologies if this is a dumb question; I am new to this stuff and am probably missing something obvious.










    share|improve this question

























      1












      1








      1


      0






      I can't for the life of me figure out how to get C++17 to work on Ubuntu 16.04.



      This works on Ubuntu 18.04:



      sudo apt-get update
      sudo apt-get install clang-6.0


      which installs the C++17 standard library headers in /usr/include/c++/7. However, when I run the same commands in Ubuntu 16.04, I get C++14 headers in /usr/include/c++/5, and C++17 features won't compile.



      I tried following this as well to install clang-7, but that led to the following error:
      clang: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'GLIBCXX_3.4.22' not found (required by clang)



      Apologies if this is a dumb question; I am new to this stuff and am probably missing something obvious.










      share|improve this question














      I can't for the life of me figure out how to get C++17 to work on Ubuntu 16.04.



      This works on Ubuntu 18.04:



      sudo apt-get update
      sudo apt-get install clang-6.0


      which installs the C++17 standard library headers in /usr/include/c++/7. However, when I run the same commands in Ubuntu 16.04, I get C++14 headers in /usr/include/c++/5, and C++17 features won't compile.



      I tried following this as well to install clang-7, but that led to the following error:
      clang: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'GLIBCXX_3.4.22' not found (required by clang)



      Apologies if this is a dumb question; I am new to this stuff and am probably missing something obvious.







      16.04 c++ clang






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 30 at 0:45









      rampatowlrampatowl

      585




      585






















          1 Answer
          1






          active

          oldest

          votes


















          1





          +50









          I followed the same article but with little changes:




          1. execute ldconfig after setting LD_LIBRARY_PATH.

          2. change the "18.04" in the url to "16.04".


          The installation was:



          apt install build-essential xz-utils curl
          curl -SL http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar -xJC .
          cp -r clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04/ /usr/local/clang-7.0.1
          export LD_LIBRARY_PATH=/usr/local/clang-7.0.1/lib:$LD_LIBRARY_PATH
          export PATH=/usr/local/clang-7.0.1/bin:$PATH
          ldconfig


          Then created if_test.cpp:



          #include <iostream>

          int main() {
          // if block with init-statement:
          if(int a = 5; a < 8) {
          std::cout << "Local variable a is < 8n";
          } else {
          std::cout << "Local variable a is >= 8n";
          }
          return 0;
          }


          The source code was compiled by following instruction:



          clang++ -std=c++17 -stdlib=libc++ -Wall -pedantic if_test.cpp -o if_test


          Execution of object file will give correct output:



          # ./if_test
          Local variable a is < 8





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2faskubuntu.com%2fquestions%2f1113974%2fusing-c17-with-clang-on-ubuntu-16-04%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1





            +50









            I followed the same article but with little changes:




            1. execute ldconfig after setting LD_LIBRARY_PATH.

            2. change the "18.04" in the url to "16.04".


            The installation was:



            apt install build-essential xz-utils curl
            curl -SL http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar -xJC .
            cp -r clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04/ /usr/local/clang-7.0.1
            export LD_LIBRARY_PATH=/usr/local/clang-7.0.1/lib:$LD_LIBRARY_PATH
            export PATH=/usr/local/clang-7.0.1/bin:$PATH
            ldconfig


            Then created if_test.cpp:



            #include <iostream>

            int main() {
            // if block with init-statement:
            if(int a = 5; a < 8) {
            std::cout << "Local variable a is < 8n";
            } else {
            std::cout << "Local variable a is >= 8n";
            }
            return 0;
            }


            The source code was compiled by following instruction:



            clang++ -std=c++17 -stdlib=libc++ -Wall -pedantic if_test.cpp -o if_test


            Execution of object file will give correct output:



            # ./if_test
            Local variable a is < 8





            share|improve this answer




























              1





              +50









              I followed the same article but with little changes:




              1. execute ldconfig after setting LD_LIBRARY_PATH.

              2. change the "18.04" in the url to "16.04".


              The installation was:



              apt install build-essential xz-utils curl
              curl -SL http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar -xJC .
              cp -r clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04/ /usr/local/clang-7.0.1
              export LD_LIBRARY_PATH=/usr/local/clang-7.0.1/lib:$LD_LIBRARY_PATH
              export PATH=/usr/local/clang-7.0.1/bin:$PATH
              ldconfig


              Then created if_test.cpp:



              #include <iostream>

              int main() {
              // if block with init-statement:
              if(int a = 5; a < 8) {
              std::cout << "Local variable a is < 8n";
              } else {
              std::cout << "Local variable a is >= 8n";
              }
              return 0;
              }


              The source code was compiled by following instruction:



              clang++ -std=c++17 -stdlib=libc++ -Wall -pedantic if_test.cpp -o if_test


              Execution of object file will give correct output:



              # ./if_test
              Local variable a is < 8





              share|improve this answer


























                1





                +50







                1





                +50



                1




                +50





                I followed the same article but with little changes:




                1. execute ldconfig after setting LD_LIBRARY_PATH.

                2. change the "18.04" in the url to "16.04".


                The installation was:



                apt install build-essential xz-utils curl
                curl -SL http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar -xJC .
                cp -r clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04/ /usr/local/clang-7.0.1
                export LD_LIBRARY_PATH=/usr/local/clang-7.0.1/lib:$LD_LIBRARY_PATH
                export PATH=/usr/local/clang-7.0.1/bin:$PATH
                ldconfig


                Then created if_test.cpp:



                #include <iostream>

                int main() {
                // if block with init-statement:
                if(int a = 5; a < 8) {
                std::cout << "Local variable a is < 8n";
                } else {
                std::cout << "Local variable a is >= 8n";
                }
                return 0;
                }


                The source code was compiled by following instruction:



                clang++ -std=c++17 -stdlib=libc++ -Wall -pedantic if_test.cpp -o if_test


                Execution of object file will give correct output:



                # ./if_test
                Local variable a is < 8





                share|improve this answer













                I followed the same article but with little changes:




                1. execute ldconfig after setting LD_LIBRARY_PATH.

                2. change the "18.04" in the url to "16.04".


                The installation was:



                apt install build-essential xz-utils curl
                curl -SL http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar -xJC .
                cp -r clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04/ /usr/local/clang-7.0.1
                export LD_LIBRARY_PATH=/usr/local/clang-7.0.1/lib:$LD_LIBRARY_PATH
                export PATH=/usr/local/clang-7.0.1/bin:$PATH
                ldconfig


                Then created if_test.cpp:



                #include <iostream>

                int main() {
                // if block with init-statement:
                if(int a = 5; a < 8) {
                std::cout << "Local variable a is < 8n";
                } else {
                std::cout << "Local variable a is >= 8n";
                }
                return 0;
                }


                The source code was compiled by following instruction:



                clang++ -std=c++17 -stdlib=libc++ -Wall -pedantic if_test.cpp -o if_test


                Execution of object file will give correct output:



                # ./if_test
                Local variable a is < 8






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 3 at 15:29









                Ping Chu HungPing Chu Hung

                63218




                63218






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • 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%2faskubuntu.com%2fquestions%2f1113974%2fusing-c17-with-clang-on-ubuntu-16-04%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

                    flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                    Mangá

                    Eduardo VII do Reino Unido