While trying to compile c++ files at CS50 ide it seemed to be not supported by clang .. is there a specific way to fix that or it's not supported at all ?

Thanks in advance

  • You are more likely to get helpful answers if you post the exact command you ran, a sample program you are trying to compile, and the error message you get when you try to compile it
    – chad
    Aug 10, 2017 at 21:16

2 Answers 2


C++ files, usually ending in .cc or .cpp (or .C with uppercase C, or a few others), can be compiled using clang++, not clang.

Those are two different frontends (the part interpreting human-made code into a large structure) to the same backend (the part taking that structure and creating computer code).

  • so it couldn't be compiled by make filename ? Aug 13, 2017 at 3:35
  • make file-to-make. Then make will search the sources for that file according to the makefile or its built-in rules. The reason is that this way make will skip any target that's newer than its sources. If it did not know the target file, it could not do that. I assume there should be standard rules for C++ files, too. Just be sure to specify the target, not the sources, and maybe write a makefile.
    – Blauelf
    Aug 14, 2017 at 7:45

Since CS50 is taught in C, they don't configure the IDE for C++ automatically. You need to have two environmental variables for this to work: CXX and CXXFLAGS. Open your profile like this:

c9 open ~/.profile

Then add these two lines:

 export CXX="clang++"
 export CXXFLAGS="-std=c++11 -Wall -Wextra -O0 -ggdb3"

Save the file and restart your terminal and it should now work. If you want to use C++14, you'll also need to edit one line in the GCC standard library that is included with the CS50 ide.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .