Prepare your computer to write Parallel code (C/C++)

Summary of what you are going to install:

  1. build-essential (including gcc/g++ etc)
  2. Open JDK
  3. C/C++ IDE (netbeans)
  4. mpich
  5. devel-mpich

Although you may use Windows or MAC OS as an operating system for your development computer, as a beginner it is recommended that you use a Linux-based distribution.

If you haven’t installed the OS read this article.

Here are the steps:

1) Update the repository (?)

sudo apt update

2) Install build essentials (?)

sudo apt install build-essential

3) Install mpich

sudo apt install mpich

4) Install mpi development libraries

sudo apt install libmpich-dev

5) Set a root password that is easy to type and remember

Ok, some people may claim this is risky but remember that we are setting up a development computer for novices. If you have important/sensitive data to the same computer (which you shouldn’t) you should skip this step. However, as a novice, you shouldn’t have sensitive data to the same computer you are writing code.

Here is a sample code that will change the root password (you will be prompt for the new one)

sudo passwd root

You will be asked for your password. Type it two times.

6) Install your desired IDE (?)

The recommended IDE for C/C++ is netbeans. Problem is that netbeans uses Java so you have to install java too. However, I still recommend netbeans, despite that drawback, since sooner or later you will need to write Java code too.

IDEs that you should NOT use, despite the fact that many universities recommend them, are: Dev C++ and similarly old IDEs that have not been updated within a year, CLion and other commercial IDE, Xcode and any other IDE that is not portable; compatible with at least three platforms: Windows, Linux, MAC OS.

If you don’t need a specific version of Java, simply install the lastest one.

For information on how to install Open JDK read this article.

Once you have Java installed, you can download netbeans and install it. If your browser users the ~/Downloads directory, the commands would be:

$ cd ~/Downloads
$ chmod a+x
$ ./  

For a more detailed tutorial on how to install java read this How-to.

If after the installation netbeans fails to compile with the message “not all requested modules can be enabled”, you can read this post.

At this point we are mostly ready. We could do some additional configuration to make our workspace more efficient.

7) Prepare your taskbar / desktop (optional)

You will be more productive if you have a tidy and clean desktop. I recommend you do the following:

Pin the following to your taskbar (or desktop):

  1. a web browser of your choice
  2. the IDE you have selected
  3. optionally a file manager like double commander, dolphin or Nemo.

Unpin or delete shortcuts to any items you don’t need.

8) Prepare your workspace for the project (optional)

If you have a specific project or assignment you want to complete then:

  1. create a folder on your desktop
  2. copy to that folder the assignment PDF, any slides and any additional resources you were given by your tutors.
  3. before our first meeting, try to compile a hello world example to save it.

9) Create an MPI project

Create a new C/C++ project in Netbeans. Then perform the following steps:

  1. Set Warning level to More warnings
  2. Set compile tool to mpicc
  3. Configure: mpiexec -n 4 “${OUTPUT_PATH}” as the default run command (set n as appropriate)
  4. Compile and test an mpi hello world project like the one shown below:
#include <mpi.h>
#include <stdio.h>

int main(int argc, char* argv[]) {
    int rank, size;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank); 
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    printf("Hello world from process %d of %d\n", rank, size);
    return 0;

10) Install additional software (optional)

You may check other useful programs according to this post.


Next step?

Once you have setup the IDE, you could install additional software:

Leave a Reply