clang++ fails to compile simple hello world c++ program
After upgrade to 14.04 from 12.04 clang++ stopped working.
$ cat test.cpp
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
$ clang++ test.cpp
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated
Installed with apt-get install clag-3.5
same happened with clang-3.4
Thanks
14.04 c++ clang
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
After upgrade to 14.04 from 12.04 clang++ stopped working.
$ cat test.cpp
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
$ clang++ test.cpp
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated
Installed with apt-get install clag-3.5
same happened with clang-3.4
Thanks
14.04 c++ clang
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
Are you able to compile it withg++
? if not usesudo apt-get install libstdc++-4.8-dev
– Salem
Aug 27 '14 at 21:19
1
of course g++ works...
– Artyom
Aug 29 '14 at 4:09
@Artyom I am see this problem on TravisCI. Everything I am reading tells me I need to compile the libc++ lib separately for Clang.
– Jared Burrows
May 10 '15 at 16:51
For those who are looking for help: stackoverflow.com/questions/22111549/….
– Jared Burrows
May 10 '15 at 17:07
add a comment |
After upgrade to 14.04 from 12.04 clang++ stopped working.
$ cat test.cpp
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
$ clang++ test.cpp
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated
Installed with apt-get install clag-3.5
same happened with clang-3.4
Thanks
14.04 c++ clang
After upgrade to 14.04 from 12.04 clang++ stopped working.
$ cat test.cpp
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
$ clang++ test.cpp
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated
Installed with apt-get install clag-3.5
same happened with clang-3.4
Thanks
14.04 c++ clang
14.04 c++ clang
asked Aug 27 '14 at 16:37
Artyom
128110
128110
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
Are you able to compile it withg++
? if not usesudo apt-get install libstdc++-4.8-dev
– Salem
Aug 27 '14 at 21:19
1
of course g++ works...
– Artyom
Aug 29 '14 at 4:09
@Artyom I am see this problem on TravisCI. Everything I am reading tells me I need to compile the libc++ lib separately for Clang.
– Jared Burrows
May 10 '15 at 16:51
For those who are looking for help: stackoverflow.com/questions/22111549/….
– Jared Burrows
May 10 '15 at 17:07
add a comment |
1
Are you able to compile it withg++
? if not usesudo apt-get install libstdc++-4.8-dev
– Salem
Aug 27 '14 at 21:19
1
of course g++ works...
– Artyom
Aug 29 '14 at 4:09
@Artyom I am see this problem on TravisCI. Everything I am reading tells me I need to compile the libc++ lib separately for Clang.
– Jared Burrows
May 10 '15 at 16:51
For those who are looking for help: stackoverflow.com/questions/22111549/….
– Jared Burrows
May 10 '15 at 17:07
1
1
Are you able to compile it with
g++
? if not use sudo apt-get install libstdc++-4.8-dev
– Salem
Aug 27 '14 at 21:19
Are you able to compile it with
g++
? if not use sudo apt-get install libstdc++-4.8-dev
– Salem
Aug 27 '14 at 21:19
1
1
of course g++ works...
– Artyom
Aug 29 '14 at 4:09
of course g++ works...
– Artyom
Aug 29 '14 at 4:09
@Artyom I am see this problem on TravisCI. Everything I am reading tells me I need to compile the libc++ lib separately for Clang.
– Jared Burrows
May 10 '15 at 16:51
@Artyom I am see this problem on TravisCI. Everything I am reading tells me I need to compile the libc++ lib separately for Clang.
– Jared Burrows
May 10 '15 at 16:51
For those who are looking for help: stackoverflow.com/questions/22111549/….
– Jared Burrows
May 10 '15 at 17:07
For those who are looking for help: stackoverflow.com/questions/22111549/….
– Jared Burrows
May 10 '15 at 17:07
add a comment |
2 Answers
2
active
oldest
votes
Your code works for me. Make sure you have libstdc++-dev installed. It's a virtual package, and in my case (Ubuntu 14.04.2 LTS) having 4.8 works.
sudo apt-get install libstdc++-4.8-dev
This doesn't work for me in Ubuntu 14.04.2.
– weberc2
Jul 27 '15 at 20:18
Just "sudo apt-get install libstdc++-dev" may work. It works for me, but there may be another package missing in your case.
– m0j0
Jul 29 '15 at 0:39
add a comment |
I found to resolve this issue that after installing libstdc++-4.8-dev
package, I need to specify the include paths and lib path to the clang++ like this.
clang++ -I/usr/include/c++/4.8/ -I/usr/include/x86_64-linux-gnu/c++/4.8 -L /usr/lib/gcc/x86_64-linux-gnu/4.8 test.cpp -o test
I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
– Sanya Phungmit
Jan 3 at 14:59
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%2f516801%2fclang-fails-to-compile-simple-hello-world-c-program%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
Your code works for me. Make sure you have libstdc++-dev installed. It's a virtual package, and in my case (Ubuntu 14.04.2 LTS) having 4.8 works.
sudo apt-get install libstdc++-4.8-dev
This doesn't work for me in Ubuntu 14.04.2.
– weberc2
Jul 27 '15 at 20:18
Just "sudo apt-get install libstdc++-dev" may work. It works for me, but there may be another package missing in your case.
– m0j0
Jul 29 '15 at 0:39
add a comment |
Your code works for me. Make sure you have libstdc++-dev installed. It's a virtual package, and in my case (Ubuntu 14.04.2 LTS) having 4.8 works.
sudo apt-get install libstdc++-4.8-dev
This doesn't work for me in Ubuntu 14.04.2.
– weberc2
Jul 27 '15 at 20:18
Just "sudo apt-get install libstdc++-dev" may work. It works for me, but there may be another package missing in your case.
– m0j0
Jul 29 '15 at 0:39
add a comment |
Your code works for me. Make sure you have libstdc++-dev installed. It's a virtual package, and in my case (Ubuntu 14.04.2 LTS) having 4.8 works.
sudo apt-get install libstdc++-4.8-dev
Your code works for me. Make sure you have libstdc++-dev installed. It's a virtual package, and in my case (Ubuntu 14.04.2 LTS) having 4.8 works.
sudo apt-get install libstdc++-4.8-dev
answered May 18 '15 at 20:07
m0j0
1156
1156
This doesn't work for me in Ubuntu 14.04.2.
– weberc2
Jul 27 '15 at 20:18
Just "sudo apt-get install libstdc++-dev" may work. It works for me, but there may be another package missing in your case.
– m0j0
Jul 29 '15 at 0:39
add a comment |
This doesn't work for me in Ubuntu 14.04.2.
– weberc2
Jul 27 '15 at 20:18
Just "sudo apt-get install libstdc++-dev" may work. It works for me, but there may be another package missing in your case.
– m0j0
Jul 29 '15 at 0:39
This doesn't work for me in Ubuntu 14.04.2.
– weberc2
Jul 27 '15 at 20:18
This doesn't work for me in Ubuntu 14.04.2.
– weberc2
Jul 27 '15 at 20:18
Just "sudo apt-get install libstdc++-dev" may work. It works for me, but there may be another package missing in your case.
– m0j0
Jul 29 '15 at 0:39
Just "sudo apt-get install libstdc++-dev" may work. It works for me, but there may be another package missing in your case.
– m0j0
Jul 29 '15 at 0:39
add a comment |
I found to resolve this issue that after installing libstdc++-4.8-dev
package, I need to specify the include paths and lib path to the clang++ like this.
clang++ -I/usr/include/c++/4.8/ -I/usr/include/x86_64-linux-gnu/c++/4.8 -L /usr/lib/gcc/x86_64-linux-gnu/4.8 test.cpp -o test
I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
– Sanya Phungmit
Jan 3 at 14:59
add a comment |
I found to resolve this issue that after installing libstdc++-4.8-dev
package, I need to specify the include paths and lib path to the clang++ like this.
clang++ -I/usr/include/c++/4.8/ -I/usr/include/x86_64-linux-gnu/c++/4.8 -L /usr/lib/gcc/x86_64-linux-gnu/4.8 test.cpp -o test
I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
– Sanya Phungmit
Jan 3 at 14:59
add a comment |
I found to resolve this issue that after installing libstdc++-4.8-dev
package, I need to specify the include paths and lib path to the clang++ like this.
clang++ -I/usr/include/c++/4.8/ -I/usr/include/x86_64-linux-gnu/c++/4.8 -L /usr/lib/gcc/x86_64-linux-gnu/4.8 test.cpp -o test
I found to resolve this issue that after installing libstdc++-4.8-dev
package, I need to specify the include paths and lib path to the clang++ like this.
clang++ -I/usr/include/c++/4.8/ -I/usr/include/x86_64-linux-gnu/c++/4.8 -L /usr/lib/gcc/x86_64-linux-gnu/4.8 test.cpp -o test
edited Jan 2 at 17:16
Marc Vanhoomissen
88611119
88611119
answered Jan 2 at 16:02
Sanya Phungmit
1
1
I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
– Sanya Phungmit
Jan 3 at 14:59
add a comment |
I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
– Sanya Phungmit
Jan 3 at 14:59
I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
– Sanya Phungmit
Jan 3 at 14:59
I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
– Sanya Phungmit
Jan 3 at 14:59
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.
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.
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%2f516801%2fclang-fails-to-compile-simple-hello-world-c-program%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
1
Are you able to compile it with
g++
? if not usesudo apt-get install libstdc++-4.8-dev
– Salem
Aug 27 '14 at 21:19
1
of course g++ works...
– Artyom
Aug 29 '14 at 4:09
@Artyom I am see this problem on TravisCI. Everything I am reading tells me I need to compile the libc++ lib separately for Clang.
– Jared Burrows
May 10 '15 at 16:51
For those who are looking for help: stackoverflow.com/questions/22111549/….
– Jared Burrows
May 10 '15 at 17:07