clang++ fails to compile simple hello world c++ program












5














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










share|improve this question














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 with g++? if not use sudo 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
















5














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










share|improve this question














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 with g++? if not use sudo 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














5












5








5







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










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 with g++? if not use sudo 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




    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




    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










2 Answers
2






active

oldest

votes


















0














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





share|improve this answer





















  • 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



















0














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





share|improve this answer























  • I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
    – Sanya Phungmit
    Jan 3 at 14:59













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%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









0














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





share|improve this answer





















  • 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
















0














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





share|improve this answer





















  • 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














0












0








0






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





share|improve this answer












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






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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













0














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





share|improve this answer























  • I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
    – Sanya Phungmit
    Jan 3 at 14:59


















0














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





share|improve this answer























  • I found another way. "clang++ -stdlib=libc++ test.cpp -o test"
    – Sanya Phungmit
    Jan 3 at 14:59
















0












0








0






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





share|improve this answer














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






share|improve this answer














share|improve this answer



share|improve this answer








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




















  • 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




















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.





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


Please pay close attention to the following guidance:


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

But avoid



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

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


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




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%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





















































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

Human spaceflight

Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

張江高科駅