Best C++ Development Environment in Linux

C++ IDE for Linux?

Initially: confusion

When originally writing this answer, I had recently made the switch from Visual Studio (with years of experience) to Linux and the first thing I did was try to find a reasonable IDE. At the time this was impossible: no good IDE existed.

Epiphany: UNIX is an IDE. All of it.1

And then I realised that the IDE in Linux is the command line with its tools:

  • First you set up your shell

    • Bash, in my case, but many people prefer
    • fish or
    • (Oh My) Zsh;
  • and your editor; pick your poison — both are state of the art:

    • Neovim2 or
    • Emacs.

Depending on your needs, you will then have to install and configure several plugins to make the editor work nicely (that’s the one annoying part). For example, most programmers on Vim will benefit from the YouCompleteMe plugin for smart autocompletion.

Once that’s done, the shell is your command interface to interact with the various tools — Debuggers (gdb), Profilers (gprof, valgrind), etc. You set up your project/build environment using Make, CMake, SnakeMake or any of the various alternatives. And you manage your code with a version control system (most people use Git). You also use tmux (previously also screen) to multiplex (= think multiple windows/tabs/panels) and persist your terminal session.

The point is that, thanks to the shell and a few tool writing conventions, these all integrate with each other. And that way the Linux shell is a truly integrated development environment, completely on par with other modern IDEs. (This doesn’t mean that individual IDEs don’t have features that the command line may be lacking, but the inverse is also true.)

To each their own

I cannot overstate how well the above workflow functions once you’ve gotten into the habit. But some people simply prefer graphical editors, and in the years since this answer was originally written, Linux has gained a suite of excellent graphical IDEs for several different programming languages (but not, as far as I’m aware, for C++). Do give them a try even if — like me — you end up not using them. Here’s just a small and biased selection:

  • For Python development, there’s PyCharm
  • For R, there’s RStudio
  • For JavaScript and TypeScript, there’s Visual Studio Code (which is also a good all-round editor)
  • And finally, many people love the Sublime Text editor for general code editing.

Keep in mind that this list is far from complete.


1 I stole that title from dsm’s comment.

2 I used to refer to Vim here. And while plain Vim is still more than capable, Neovim is a promising restart, and it’s modernised a few old warts.

IDE for C/C++ programming in Linux

My personal favorite is KDevelop. I've never used its debugger (I use straight gdb) but its code completion and documentation viewers are excellent. One of the best you'll every find. Also, it's not written in Java but C or C++, so it runs faster on worse systems.

Best C++ development environment in Linux

I definitely recommend Eclipse and the CDT plugin. Emacs would be my preferred choice if you only need a good editor and not a full IDE.

I use Eclipse almost every day on Linux, mostly for C++ programming these days. The CDT plugin is really good because it is very well integrated with the g++ compiler and the gdb debugger. On top of that, the really strong feature of CDT is the code indexer - i.e. what Microsoft calls "intellisense" for Visual Studio. The CDT Indexer is so sophisticated it is almost like a compiler, in that it really understands your code as you type it. Very often it allows me to find errors even before I build my project. Also Eclipse can handle very large source trees, especially if you run it with a 64-bit JVM.

Eclipse is a great IDE with a lot of users, and if you don't know any other IDE you may want to start with it. Because it supports many languages and has so many tools, even if you switch to another project with different technologies you can still keep your IDE. So you only need to learn one tool (the same can be said for Emacs).

What is the best IDE for C Development / Why use Emacs over an IDE?

I started off by using IDEs, Microsoft or not. Then, while working on QNX some long time ago, I was forced to do with a text editor + compiler/linker. Now I prefer this simple combination––a syntax highlighting editor + C compiler and linker cli + make––to any IDEs, even if environment allows for them.

The reasons are, for me:

  1. it's everywhere. If you program in C, you do have the compiler, and usually you can get yourself an editor. The first thing I do––I get myself nedit on Linux or Notepad++ on Windows. I would go with vi, but GUI editors provide for a better fonts, and that is important when you look at code all day

  2. you can program remotely, via ssh, when you need to. And it does help a lot sometimes to be able to ssh into the target and do some quick things there

  3. it keeps me close to CLI, preferably UNIX/Linux CLI. So all the commands are on my fingertips, and when I need them I don't have to go read a reference book. And UNIX CLI can do things IDEs often can't––because their developers didn't think you'd need them

  4. most importantly, it is very much like seeing the Matrix in raw code. I operate files, so I'm forced to keep them manageable. I'm finding things in my code manually, which makes me keep it simple and organized. I do Config Management explicitly, so I know when I'm synced and how. I know my Makefiles because I write them, and they only do what I tell them to

    (if you wonder if that works in "really big projects"––it does work, and the bigger the project the more performance it gains me)

  5. when people ask me to look at their code, I don't have to learn the IDE they use

Good C++ Debugging/IDE Environment for Linux?

Although many people think of it as a Java IDE, he could try NetBeans. I've used it on Windows for C and C++ development without a problem, and I know NetBeans is supported on Linux, so it would be worth a shot.

It looks like most of the features he wants are included in the C/C++ development toolkit, including integration with GDB, a profiler, and more.

Setting up a Programming Environment in Linux

Standard stuff:

  • The compiler tools, gcc, gdb, etc.
  • Some sort of editor/IDE (emacs, vim, eclipse)
  • Profiling tools
  • Source Control (SubVersion, git, etc)
  • Language specific tools, like easy_install for python (you said C/C++, but the same goes for everything)
  • A web server maybe? Apache, Lighttpd, nginx
  • Any libraries you'll be using. Are you doing kernal hacking? Driver development? opengl?

Best C++ IDE for *nix

On Ubuntu, some the IDEs that are available in the repositories are:

  • Kdevelop
  • Geany
  • Anjuta

There is also:

  • Eclipse (Recommended you don't install from repositories, due to issues with file/folder permissions)
  • Code::blocks

And of course, everyone's favourite text-based editors:

  • vi/vim
  • emacs

Its true that vim and emacs are very powerful tools, but the learning curve is very steep..

I really don't like Eclipse that much, I find it buggy and a bit too clunky.

I've started using Geany as a bare-bones but functional and usable IDE. It has a basic code-completion feature, and is a nice, clean [Gnome] interface.

Anjuta I tried for a day, didn't like it at all. I didn't find it as useful as Geany.

Kdevelop and code::blocks get a bunch of good reviews, but I haven't tried them. I use gnome, and I'm yet to see a KDE app that looks good in gnome (sorry, I'm sure its a great program).

If only bloodshed dev-c++ was released under linux. That is a fantastic (but windows-only) program. You could always run it under Wine ;)

To a degree, it comes down to personal preference. My advice is to investigate Kdevelop, Geany and code::blocks as a starting point.

Tools used for programming in Linux

For the language it really depends what you want to do :

  • C is good for low level software, specially if performance is a priority, otherwise syntax can be painful for a first programming experience.
  • C++ is good for high level software and has a lot of good qualities that C misses (e.g. classes, operator/function overload), but may require some good knowledge of C in case of serious trouble.
  • if it is really your first programming experience, maybe learning with an interpreted language like Python/Perl could be a good idea to begin with.

For the text editor you have:

  • the good old classics: emacs/VIM, I don't want to argue about the choice
  • graphical editors: gedit, gvim, kate. Personally, I really like kate.
  • IDE: kdevelop, anjuta, eclipse, netbeans. Personally I use netbeans for C/C++ development. Again, if it is a first experience, maybe beginning with an IDE is not a great idea to make things clear.

For the compiler, unless you have special needs, you don't need something else than GCC.

Setting up environment for learning C

I recommend you use VirtualBox to create a virtual machine. This is best because it sandboxes your development environment and you get a real Linux environment to work in. VirtualBox is free and open source and you probably won't need any advanced features you might see in VMWare or Parallels.

  • Download VirtualBox (https://www.virtualbox.org/wiki/Downloads)
  • Download Ubuntu server (https://www.ubuntu.com/download/server)
  • Create a new virtual machine (VM)
  • Mount the Ubuntu ISO file to the VM (Settings -> Storage, check 'Live CD/DVD' and click the disk icon to browse for the ISO)
  • Boot up the VM and install Ubuntu by following the on-screen instructions

Now that you have the environment built you can create a directory where your project folders go. From the prompt just do mkdir projects, cd projects, mkdir helloworld, cd helloworld. Then, you can use the built-in editor nano to edit files. Type nano hello.c and then enter the following:

#include <stdio.h>
int main()
{
printf("Hello, world\n");
}

Then type Ctrl-O to write out and then Ctrl-X to exit.

Then you just need to install gcc and I would suggest installing make as well:

$ sudo apt install gcc
...
$ sudo apt install make

Now to compile and test your first program in your development environment:

$ make hello
$ ./hello

Then you should see Hello, world on your screen.

Valgrind and Un-mount Disk

From your helloworld project folder enter sudo apt install valgrind, then run valgrind ./hello.

Finally, go to Settings -> Storage and un-mount the installation ISO.

SSH Access

Install openssh-server using the following command:

sudo apt install openssh-server

Find the IP address of your Ubuntu host by typing ifconfig. Then for VirtualBox go to Settings :: Network :: Advanced and click Port Forwarding. Use these settings:

Host IP: 127.0.0.1
Host Port: 22
Guest IP: (IP of Ubuntu VM)
Guest Port: 22

Now you can ssh to your Ubuntu VM and also use tools like scp.

Shared Folders

Shared folders allow you to have a medium that spans both file systems, allowing you to share files between the two environments. This resource offers a lot more detail in the different methods: https://www.virtualbox.org/manual/ch04.html#sharedfolders. I will go over how to set this up quickly in the setup detailed here.

The following will install the Linux headers required for VirtualBox shared folders:

sudo apt-get install build-essential linux-headers-`uname –r`

Then go to the Devices tab of the VirtualBox menu and click Insert Guest Additions CD image....

Now we need to mount the cdrom and run the script:

sudo mount /dev/cdrom /media/cdrom
sudo /media/cdrom/VBoxLinuxAdditions.run

Figure out what Windows folder you want to share, and share it by going to VirtualBox guest Machine :: Settings :: Shared Folders and add it with the options Auto-mount and Make Permanent. When you're done, do a sudo reboot.

The shared folders are automatically added and exist in /media/sf_*.

You must be in the vboxsf group to work with those files. Use this command to add a user testuser to that group:

sudo usermod -aG vboxsf testuser
sudo reboot


Related Topics



Leave a reply



Submit