Compiling & Debugging MariaDB(and MySQL) in Eclipse from scratch – Part 1: “Setup the building environment”

This guide will help you in compiling and debugging MariaDB (MySQL, Percona) within the Eclipse IDE on Linux and using cmake for source project preparation.

It will be split in parts to keep each post lightweight and with a finite objective.

At the end of reading this series of blog posts you should be able to:

  1. Prepare for compilation any MariaDB (MySQL, Percona) source release based on cmake framework.
  2. Compile MariaDB (MySQL, Percona) both in command line and under Eclipse IDE.
  3. Debug step by step MariaDB (MySQL, Percona) release under Eclipse IDE.

Additionally, with some extra effort, you may get to:

  1. Profile MariaDB execution under Eclipse.
  2. Patch and compile your own modified version of MariaDB(MySQL, Percona).

Any Linux distribution with Eclipse and the C++ toolkit can be used.

The distribution I have used for this guide is CentOS 6.5 i386 (32bit) and I have used the VirtualBox Centos 6.5 i386 VDI downloaded from:

If you have already a Linux distribution complete with the C++ toolkit and Eclipse you can skip Section 1 (or this blog post entirely and go to Part 2).

This guide can be used with any MariaDB, MySQL, Percona releases that supports cmake framework,

I have tested this method with several (not all) versions 5.5 or higher, in this guide we will use with MariaDB 10.0.x.


Note: On other distributions than CentOS both the package manager(eg: yum, apt, etc..) and the package names may differ, being this guide based on CentOS 6.5 the commands are guaranteed to work on such distributions but may need some changes for other distributions, I will try to explain the meaning of each section so that you can find help for your distribution if needed. Refer to your distribution specific instructions for more details.

1.1 Install a Graphical Desktop Environment

The Virtual Disk Image I use is a ‘Basic’ server version, which means no graphical interface is installed, for this we will proceed and install the default graphical desktop environment(GNOME).

$ yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts"

1.2 Add a developer user

You can use any username you wish, just remember this user will be used to compile, debug and run mysqld, this includes the ownership of the ‘badedir’ and ‘datadir’.

$ sudo useradd -G wheel yoda

wheel in CentOS(and others) is the group name of the users that can run sudo, feel free to configure at your wish the sudo privileges if you are able to do so.

1.3 Install C++ Toolkit

We need the C++ development toolkit (gcc,make,automake,patch, etc), cmake, libaio headers and ncurses headers:

$ sudo yum groupinstall 'Development Tools'

$ sudo yum install cmake

$ sudo yum install libaio-devel

$ sudo yum install ncurses-devel

At this point the server should be able to compile via command line, you may want to do a simple test:

$ echo "#include <stdio.h>



      printf("Hello world\n");

   }" > test.c

$ gcc test.c

$ ./a.out

And you should see:

Hello world

If you see Hello world you have compiled correctly the test.c file, you can proceed now to setup Eclipse.

1.4 Install Eclipse CDT

Note: If you have already Eclipse you may just add the CDT (C++ Development Toolkit), refer to Eclipse manual for details.

To download Eclipse you can go to:

Choose: “Eclipse IDE for C/C++ Developers(CDT)”

Eclipse CDT includes customizations to compile, debug and profile C/C++ applications in Eclipse.

Download and install as showed on the Eclipse website instructions.

At this point you should have:

  • Graphical Desktop Manager
  • C++ toolkit  (gcc, make, cmake, etc…)
  • Eclipse CDT

Note: If you don’t have all of the above points working do not continue for Part 2.

The preparation is finished, if you had to do each task described in this post you have probably spent quite some time, here it ends Part 1.