I’m on a mission to try and build darktable from source. This has turned out to be bit more of a challenge than I expected, not least because what little documentation exists on this subject is either grossly inadequate or out of date or both. Trust me when I say I visited ALL the links you can find on Google about this. There are no instructions that work out of the box.
So I went my own way and managed to get a good part of the work done. Actually to the point of getting a success return code out of cmake and a finished binary. The problem is that the final executable is dynamically linked and contains references to dependencies I don’t have.
I guess that doesn’t make a lot of sense so let me explain how I build darktable, in case anyone else feels up to the challenge.
Step 1: Dependencies
Yes and there are SO many dependencies to have in place before you even think of starting a build. Fortunately the developers were sensible enough to use docker to setup the Travis CI build environment and we can help ourselves to the Dockerfile they use for that. All you need is to install docker on your local machine (sudo apt install docker.io I think on Ubuntu).
Go to darktable/.ci at master · darktable-org/darktable · GitHub and grab the Dockerfile from there. Now go to a command line and execute:
$ docker build - < Dockerfile
(tons of output)
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> 7fb36dc89c21 2 hours ago 2.05GB
Copy the image id, you’ll need it for later. You can also name the image but for this purpose we don’t care what the image is called.
Right so now we have an image which is almost suitable for a build. I execute the following interactively but you could of course stuff all this into the Dockerfile if you wanted.
$ docker run -it <IMAGE-ID-FROM-ABOVE> bash root@77d58544b6e4:/# apt update && apt install build-essential (tons of output) root@77d58544b6e4:/# mkdir github root@77d58544b6e4:/# cd github root@77d58544b6e4:/# git clone --depth=1 https://github.com/darktable-org/darktable.git (tons of output) root@77d58544b6e4:/# cd darktable root@77d58544b6e4:/# git submodule init && git submodule update
Step 2: Compiling darktable
Finally we’re ready to build. We do it the easy way, as per the instructions on GitHub - darktable-org/darktable: darktable is an open source photography workflow application and raw developer
root@77d58544b6e4:/# ./build.sh --prefix /opt/darktable --build-type Release
Now go grab yourself a cup of coffee, this will take a while. Lots of output truncated here for brevity, but you will see something like this at the end:
[100%] Linking CXX shared module libdemosaic.so [100%] Built target demosaic darktable finished building. To actually install darktable you need to type: $ cmake --build "/github/darktable/build" --target install -- -j8
Step 3: Building the final binary
Right so we do what the build script kindly asks us to:
root@77d58544b6e4:/# cmake --build "/github/darktable/build" --target install -- -j8
(lots of output)
Now, witness with amazement the built binary of darktable:
root@77d58544b6e4:/# ls -la /opt/darktable/bin total 25244 drwxr-xr-x 2 root root 4096 Jan 22 18:40 . drwxr-xr-x 5 root root 4096 Jan 22 18:40 .. -rwxr-xr-x 1 root root 25056 Jan 22 18:40 darktable -rwxr-xr-x 1 root root 466376 Jan 22 18:40 darktable-chart -rwxr-xr-x 1 root root 97704 Jan 22 18:40 darktable-cli -rwxr-xr-x 1 root root 36328 Jan 22 18:40 darktable-cltest -rwxr-xr-x 1 root root 52816 Jan 22 18:40 darktable-cmstest -rwxr-xr-x 1 root root 49792 Jan 22 18:40 darktable-generate-cache -rwxr-xr-x 1 root root 25100304 Jan 22 18:40 darktable-rs-identify
Okay. Now we finally get to the crux of the problem, namely that I want to copy that sucker out of the docker container and use it on my host machine. Think that will work? Let’s try it.
Open another terminal window. Note: DO NOT EXIT the container! If you’re not familiar with Docker, that container and everything in it pretty much disappears when you exit it. You’d have to start over with the build process.
(note: substitute your own container id, it’s the big number in the command prompt from inside the container, or find it with “docker container ps”)
hostmachine$ docker cp 77d58544b6e4:/opt/darktable/bin .
Great, we have it now. Let’s run it:
hostmachine$ bin/darktable bin/darktable: error while loading shared libraries: libdarktable.so: cannot open shared object file: No such file or directory
Ah. Yeah. Bummer. The thing is obviously dynamically linked and on the host we have none of those dependencies. You can actually grab the libdarktable.so from the lib folder of the build as well, but that just leads to the next missing dependency (libIlmImf-2_3.so.24).
So. Now you know where I’m at. Is there a way to build darktable with statically linked objects? I tried using LDFLAGS="-static" on the cmake commands but that didn’t work - it was a long shot of course.
If anyone can help me along so I can run any branch or tag of darktable from source I’d appreciate it very much.