How to setup Eclipse CDT with Darktable in Windows and Linux

I have been requested to post a guide about setting Eclipse IDE for Darktable, so here it is.
This guide assumes that you are already able to build Darktable from sources in Windows (through MSYS2) and/or Linux, by using the command line.
Some basic knowledge of Eclipse is also required.
If you want to contribute to Darktable project, normally you need to create your own fork of the project in GitHub.
We assume that Darktable sources are in

  • (for Windows) C:\msys64\home\<username>\develop\darktable
  • (for Linux) ~/develop/darktable

Step 1. Install Ecplise CDT from website

Step 2. From the Ecplise Marketplace, search and install the addon cmake4eclipse

Step 3. Import Darktable source code

In eclipse: File→ New → Project → C/C++ → C++ Project
In the dialog, choose “Linux GCC toolchain” and point to the source code folder. See below

Hit “Finish”

Step 4. Set Project Properties

Go to the properties of the newly created Eclipse project. For example in Project explorer window, right click on the project → Properties

Setup as follows (hit “Apply” at every step)

For Windows, in C/C++ Build → Cmake4eclipse → Host OS overrides → Windows, make sure the option “Buildscript generator (-G)” is set to “Unix Makefiles”.
For Linux it should be already set correctly.

In C/C++ Build → Settings → Binary Parsers:

  • for Windows, select only “WE64 Windows Parser”
  • for Linux, select only “GNU Elf Parser”

Hit “Apply and Close”

Step 5. Build the project

Eclipse should run CMake first and then make install, you can see the output in the appropriate console.

The initial build will give some errors related to failing build of user manual, that is not a problem.

Incremental builds shall not give errors.

Step 6. Create a run configuration

For Windows

For Linux, just omit the .exe

Now Eclipse should be able to run and debug Darktable.

Of course you can now customize Eclipse behaviour and appearance to your liking.

Known issues

  • In general, building and debugging in Linux is much faster.
  • I couldn’t find a way to run Darktable “in place”, without installing. This adds an extra step at every build, which is quite fast in Linux, but pretty slow in Windows, especially because CMake runs the fixup_bundle utility at the end of every install, which is slow. Preventing this requires commenting a couple of lines in CMakeFiles.txt. Happy to hear if someone finds a better way to run Darktable without installing.
  • In Windows, when running GDB, the keyboard inputs respond very slow. This is a bug in Gtk+. To avoid it, it is needed to build a custom version of Gtk+, but I have never tried.

Feel free to comment / modify / improve.

4 Likes

I don’t know Eclipse.
Does Eclipse allow to debug, ie. set breakpoint, inspect variables, etc… ?
Thanks

Yes, although I only have used the Java debugging tools (which are pretty nice), so I can’t comment on the C++ ones

1 Like

Yes, it uses GDB

1 Like

So let’s go. Trying to install.
Step 4, first screenshot, setting Current toolchain Cmake driven I get this message:

Is that related to the eclipse installation process or to the dt project itself ?
Note: the first time I’ve tried to install cmake4eclipse it failed, but did well the second time.

Please confirm that you have MSYS2 installed and that you are able to build Darktable from the MinGW64 command line as per this instruction.
Also, double check that your windows PATH includes the following folders

C:\msys64\mingw64\bin
C:\msys64\usr\bin

I’m on Debian 10, and |I’m able to build darktable.
Of course the build folder is already present in in my darktable folder.

Oops, sorry, I thought you were on Windows.
I have never seen that error, I have tested the procedure on Ubuntu 19.10, I wonder what could be different on Debian…
As Eclipse requires Java, what JRE are you using? I have OpenJDK.
Maybe trying to uninstall and reinstall cmake4eclipse.
Also, try to continue the procedure, to see if you get other errors more explanatory.

Not a pb. I’ve been there (and sometimes I go back there to check some dt issues).

I’ve deleted the full eclipse folder and reinstalled everything. Same issue. But I suspect the first download of cmake4eclipse didn’t go well and the subsequent installs still use it. I’ve to find out it somewhere in the cache …

I’ve cleaned up the cache and started again the installation.
Here is the error I get when trying to install cmake4eclipse:

An error occurred while collecting items to be installed
session context was:(profile=_home_philippe_eclipse_cpp-2019-12_eclipse, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Unable to read repository at jar:https://dl.bintray.com/15knots/p2-zip/cmake4eclipse-2.1.1.zip!/plugins/de.marw.cdt.cmake.core_1.15.0.202002111902.jar.
Read timed out
Unable to read repository at jar:https://dl.bintray.com/15knots/p2-zip/cmake4eclipse-2.1.1.zip!/features/de.marw.cdt.cmake_2.1.1.202003091558.jar.
Read timed out
Unable to read repository at jar:https://dl.bintray.com/15knots/p2-zip/cmake4eclipse-2.1.1.zip!/plugins/de.marw.cmake.cdt_1.0.3.202003071623.jar.
Read timed out

I’m sorry to hear this.
Unfortunately I don’t know how to help you, for me cmake4eclipse installed just fine on Windows and Ubuntu.
Maybe you can open a bug on the cmake4eclipse project site at github
https://github.com/15knots/cmake4eclipse
They seem to be very active.
Good luck

I want to thank you for this posting. I followed it exactly and had no problem building darktable. I’m using eclipse version 2021-03 with Ubuntu 21.04 running under VirtualBox.

You might want to add a comment that after the buildscript has been generated the darktable build can be seen running in the lower right corner of eclipse. There is no other indicator that the build is working. It took a bit of time (several minutes) for the build to complete. Someone not paying attention might think that there was something wrong.

Again, thanks.

2 Likes

I am happy to hear you found the guide useful.
Actually you can follow all the build process if you go in the Eclipse console, but yes this can be explained better