21

The question is in the title.

So far I've only used IntelliJ for Java. Do I need to download some sort of Compiler or how can I create C++ files?

sepp2k
  • 363,768
  • 54
  • 674
  • 675

2 Answers2

12

Like @dddavid said,there is an IDE made by JetBrains for C/C++ called Clion. It is quite easy to use if you are familiar with intelliJ

However, if your question is how to compile and run C/C++ in intelliJ, there are still ways for you! (Which is not recommended if you are trying to develop large project in C/C++ in intelliJ.)

If you really want to do that, there is a terminal in intelliJ. If you are in linux system, try to get gcc for C and g++ for C++. If you are in windows system, you can try to get mingw or other compilers for C/C++.

After getting the compiler, you could simply type commands in the terminal inside intelliJ to compile C/C++ and run it.

For example, if you are in linux with g++, if you wants to compile main.cpp: Follow these step:

  1. type g++ main.cpp in the terminal inside intelliJ

  2. type ./a.out in the terminal inside intelliJ

And it will start to run your C/C++ program!

Daadii
  • 3
  • 3
Jim Pp
  • 147
  • 4
  • This is the greatest answer, but there are a couple of pitfalls. CLion does burn a hole in the pocket for Indian students because we don't usually have an email ID given to us by the our schools or universities. So it would be really helpful if we had a plugin for C++ in IntelliJ IDEA free of cost. – Aritro Shome Apr 15 '21 at 12:45
  • @AritroShome You don't need to have a school email, it's just easier. They'll take documents that prove your student status too! GitHub Education does the same thing and includes JetBrains as well. --- Jetbrains: "Options to get a free educational license... GitHub Student Developer Pack account... Student’s/teacher’s ID or other official document" --- GitHub: "Have a verifiable school-issued email address or upload documents that prove your current student status." – Aido Sep 01 '21 at 12:55
1

You should use CLion instead. It's the JetBrains IDE for C/C++.

dddavid
  • 90
  • 1
  • 2
  • 43
    His question is about C++ in IntelliJ IDEA, not CLion. – Matas Lesinskas Apr 27 '21 at 10:42
  • 11
    Yeah but CLion costs money! There is no community version. – Kleysley Jul 27 '21 at 13:59
  • 1
    After all, you may use Trial or EAP versions of CLion, or buy the product if it is your work horse. And as far as I can see right now in my 1 year old Community version of Idea, syntax highlighting just works, and you may easily edit, say most of your competitive or educational tasks and compile from command line, that's quite enough for many cases. – WebComer Jan 17 '22 at 21:39
  • As of 2023, EAP versions stop working when the new version is released. – Åsmund Aug 04 '23 at 07:23
  • Clion isn't particularly helpful if what you're working on is a mixed-language Java/C++ project. Really, there should be an easy environment where you can work on both without needing to switch IDEs all the time... – occipita Aug 05 '23 at 13:45
  • @occipita True. In that case I would set up visual studio code (actually, it is my daily driver for pretty much anything these days). I don't know about any IDE with customization options/integration coming close code. I mentioned CLion in the original answer because the question was about IntelliJ, so I stuck to jetbrains products. – dddavid Sep 01 '23 at 06:54