Using C++17 with clang++ on Ubuntu 16.04
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
add a comment |
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
add a comment |
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
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
16.04 c++ clang
asked Jan 30 at 0:45
rampatowlrampatowl
585
585
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I followed the same article but with little changes:
- execute
ldconfig
after settingLD_LIBRARY_PATH
. - 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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
I followed the same article but with little changes:
- execute
ldconfig
after settingLD_LIBRARY_PATH
. - 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
add a comment |
I followed the same article but with little changes:
- execute
ldconfig
after settingLD_LIBRARY_PATH
. - 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
add a comment |
I followed the same article but with little changes:
- execute
ldconfig
after settingLD_LIBRARY_PATH
. - 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
I followed the same article but with little changes:
- execute
ldconfig
after settingLD_LIBRARY_PATH
. - 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
answered Feb 3 at 15:29
Ping Chu HungPing Chu Hung
63218
63218
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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