Compiling RawTherapee Dev branch on OSX

Hi all,

I am trying to compile the dev version of RT on OSX Catalina 10.15.17. I installed all dependencies via Brew, and then use the cmake command below, following the instructions on the wiki page of RT. Only a few warnings appear during compiling, and in the end I manage to generate the OSX_bundle and executable (170.1MB, which oddly is much smaller than the 188.5MB downloaded RT5.8-397 version I usually run). After moving RawTherapee.app to /Applications, the executable crashes. I tried small modifications to the cmake command, but I am unable to get a working executable… Any ideas what I am doing wrong? I can post output of cmake, if needed, but perhaps I am doing something obvious wrong?

Thanks in advance for your help in this!

I use ‘git checkout dev’ to select dev branch code. Should I select something different to get the latest dev? I tried checking out several other tags but no luck there.

My compiler is:

Apple clang version 12.0.0 (clang-1200.0.32.21)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I tried to use the compiler from llvm, which is 11.0.0, but then my cmake crashes after trying to test the compiler.Could not find a way to circumvent the testing step…

My cmake command:

cmake … -DCMAKE_BUILD_TYPE=“release” -DPROC_TARGET_NUMBER=“2” -DCACHE_NAME_SUFFIX=“5.8-dev” -DCMAKE_C_COMPILER=“clang” -DCMAKE_CXX_COMPILER=“clang++” -DWITH_LTO=“ON” -DLENSFUNDBDIR="/Applications/RawTherapee.app/Contents/Resources/share/lensfun" -DCMAKE_BUILD_TYPE=Release -DOpenMP_C_FLAGS=-fopenmp=libomp -DOpenMP_CXX_FLAGS=-fopenmp=libomp -DOpenMP_C_LIB_NAMES=“libomp” -DOpenMP_CXX_LIB_NAMES=“libomp” -DOpenMP_libomp_LIBRARY="/usr/local/lib/libomp.dylib" -DOpenMP_CXX_FLAGS="-Wno-pass-failed -Wno-deprecated-register -Xpreprocessor -fopenmp /usr/local/lib/libomp.dylib -I/usr/local/include" -DOpenMP_CXX_LIB_NAMES=“libomp” -DOpenMP_C_FLAGS="-Wno-pass-failed -Wno-deprecated-register -Xpreprocessor -fopenmp /usr/local/lib/libomp.dylib -I/usr/local/include" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/opt/libffi/lib -L/usr/local/lib" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.15”

Followed by the usual make -j$(sysctl -n hw.ncpu) install & sudo make osx_bundle.

@HIRAM is your person!

What do you mean by “my cmake crashes”?

Thanks for your reply. I change the compiler to the llvm 11.0.0 version like it is described on the wiki:

cmake … -DCMAKE_BUILD_TYPE=“release” -DPROC_TARGET_NUMBER=“2” -DCACHE_NAME_SUFFIX=“5.8-dev” -DCMAKE_C_COMPILER="/usr/local/Cellar/llvm/11.0.0/bin/clang" -DCMAKE_CXX_COMPILER="/usr/local/Cellar/llvm/11.0.0/bin/clang++" -DWITH_LTO=“ON” -DLENSFUNDBDIR="/Applications/RawTherapee.app/Contents/Resources/share/lensfun" -DCMAKE_BUILD_TYPE=Release -DOpenMP_C_FLAGS=-fopenmp=libomp -DOpenMP_CXX_FLAGS=-fopenmp=libomp -DOpenMP_C_LIB_NAMES=“libomp” -DOpenMP_CXX_LIB_NAMES=“libomp” -DOpenMP_libomp_LIBRARY="/usr/local/lib/libomp.dylib" -DOpenMP_CXX_FLAGS="-Wno-pass-failed -Wno-deprecated-register -Xpreprocessor -fopenmp /usr/local/lib/libomp.dylib -I/usr/local/include" -DOpenMP_CXX_LIB_NAMES=“libomp” -DOpenMP_C_FLAGS="-Wno-pass-failed -Wno-deprecated-register -Xpreprocessor -fopenmp /usr/local/lib/libomp.dylib -I/usr/local/include" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/opt/libffi/lib -L/usr/local/lib" -DCMAKE_AR="/usr/local/Cellar/llvm/11.0.0/bin/llvm-ar" -DCMAKE_RANLIB="/usr/local/Cellar/llvm/11.0.0/bin/llvm-ranlib" -DCMAKE_OSX_DEPLOYMENT_TARGET=“10.15”

`then I get the following error:

– CMAKE_BUILD_TYPE: Release
usage: ar -d [-TLsv] archive file …
ar -m [-TLsv] archive file …
ar -m [-abiTLsv] position archive file …
ar -p [-TLsv] archive [file …]
ar -q [-cTLsv] archive file …
ar -r [-cuTLsv] archive file …
ar -r [-abciuTLsv] position archive file …
ar -t [-TLsv] archive [file …]
ar -x [-ouTLsv] archive [file …]
– Binutils version detected as less than 2.29 - setting CMake parameters to enable LTO linking:
CMAKE_AR="/usr/bin/ar"
CMAKE_RANLIB="/usr/bin/ranlib"
– Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/local/Cellar/llvm/11.0.0/bin/clang
CMAKE_CXX_COMPILER= /usr/local/Cellar/llvm/11.0.0/bin/clang++

– The C compiler identification is Clang 11.0.0
– The CXX compiler identification is Clang 11.0.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - failed
– Check for working C compiler: /usr/local/Cellar/llvm/11.0.0/bin/clang
– Check for working C compiler: /usr/local/Cellar/llvm/11.0.0/bin/clang - broken
CMake Error at /usr/local/Cellar/cmake/3.19.1/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler

"/usr/local/Cellar/llvm/11.0.0/bin/clang"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /Users/myname/programs/code-rawtherapee/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_94c40/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_94c40.dir/build.make CMakeFiles/cmTC_94c40.dir/build
Building C object CMakeFiles/cmTC_94c40.dir/testCCompiler.c.o
/usr/local/Cellar/llvm/11.0.0/bin/clang   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -o CMakeFiles/cmTC_94c40.dir/testCCompiler.c.o -c /Users/myname/programs/code-rawtherapee/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_94c40
/usr/local/Cellar/cmake/3.19.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_94c40.dir/link.txt --verbose=1
/usr/local/Cellar/llvm/11.0.0/bin/clang  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_94c40.dir/testCCompiler.c.o -o cmTC_94c40 
ld: library not found for -lSystem
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_94c40] Error 1
make: *** [cmTC_94c40/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:24 (project)

– Configuring incomplete, errors occurred!
See also “/Users/myname/programs/code-rawtherapee/build/CMakeFiles/CMakeOutput.log”.
See also “/Users/myname/programs/code-rawtherapee/build/CMakeFiles/CMakeError.log”.

Ok, anytime you change the config, always rerun cmake from a new empty build dir… report any further errors.

The same error shows for llvm clang 11.0.0 when I start all clean. When I use the clang compiler 12.0.0 in the first cmake command, it skips that compiler test where 11.0.0 fails:

– The C compiler identification is AppleClang 12.0.0.12000032
– The CXX compiler identification is AppleClang 12.0.0.12000032
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: /usr/bin/clang - skipped
– Detecting C compile features
– Detecting C compile features - done
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: /usr/bin/clang++ - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
– CMAKE_BUILD_TYPE: release
etc…

I tracked down the error “ld: library not found for -lSystem” to this. Tried to modify CMakeLists.txt as suggested:

set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH YES)

But nothing changes.

What I don’t get is that the executable that I compile using 12.0.0 doesn’t work. Does that happen often? I am not well versed in compiling/programming, but usually get stuff to work, but this really puzzles me.

FWIW I tried this many times and failed.
I gave up, installed Parallels and Linux Mint and run the nightly build from in there - works a charm and you can update it every day if you wish.

Hi Andy,

Indeed, that would be a relatively easy fix for me also, but I am worried that my Macbook 12inch retina from 2016 with max 8GB RAM is not powerful enough to run avirtualmachine like parallels efficiently. Already experience regular crashes for my downloaded RT 5.8-397 build, possibly due to memory issues. This is why I would prefer to generate a `cpu-optimised ‘native’ build. Were you also able to successfully compile and generate the executable, but then couldn’t get the executable run properly?

The other option is to wait for the 5.9 release, but completely unclear when that will be, and if an OSX version will be rolled out. For other software like Gimp, the OSX version always seems to be significantly delayed compared in Win/linux. Perhaps I should invest again in a linux box again…

If you have issues on the 5.8.397 build, have you reported them? One reason for delays is that people experience a crash but forget to report… 8GB is not nearly enough RAM for this exercise…

Hi Hiram, I would be happy to report issues with builds on OSX, but it this case it does not seem to be linked to a specific thing I do in RT. It often happens randomly when I move from one picture to another in the top panel where my images in the working folder are, which makes me the think it is more a general RAM memory issue, but I could be wrong. FYI, I have edited 1000’s of pictures with this build and the 5.8 release version, and succesfully used all its advanced tools, even memory intensive ones like Wavelets at D14 edge performance, tone mapping and DRC, on my MacBook. I keep track of RAM using Memory Clean and usually have 1.5GB left when using RT. What would you need from my side? I can attach the crash report when it happens again. Anything else?

Yes the macOS Crash Report can help quickly identify candidate problems usually involving a 3-rd party code library. 8GB is a low low number for digital photo on macOS. If you are intending to preserve a mac laptop, definitely max out the RAM.

Here is the crash report for my own compilation of RT dev. Hope this gives some clues:

EXECRASH.txt (74.1 KB)

See also here for the crash output for ART, which seems the same as for RT.

I will post a crash report for my working RT 5.8-397, but it did not happen recently.

@HIRAM, did you have time to have a look at my crash reports for RT and ART? Should I give up trying to compile for myself and wait for the official 5.9 release?