[solved] dcamprof compilation for M1 mac (arm64)

After reading Rawpedia How to create DCP color profiles - RawPedia
I’m attempting to compile DCamProf for my M1 mac but I’ve yet to find out which adjustments I need to do in the Makefile.

Has anybody succeeded in compiling DCamProf, here, for an M1 mac (i.e. Apple ARM64)?

Thanks for your input.

Not a Mac person, but I’ve compiled dcamprof and it’s really pretty light. It only depends on LittleCMS and libtiff, and you need a GNU-like make. If you’re using gcc, the Makefile should work right out of the box, but if you’re using clang you’ll need to change the CC = at line 3 to the compiler name. There are a few switches in the compiler command line; I think they’d all work with clang…

1 Like

Thanks for reacting.

  • Dependencies (esp. LittleCMS, libtiff):
ls -1 $(brew --prefix)/Cellar/{libtiff,little-cms,gcc,libomp,llvm}
/opt/homebrew/Cellar/gcc:
11.2.0_3/

/opt/homebrew/Cellar/libomp:
11.1.0/
12.0.0/

/opt/homebrew/Cellar/libtiff:
4.3.0/

/opt/homebrew/Cellar/little-cms:
1.19_1/

/opt/homebrew/Cellar/llvm:
13.0.1_1/
  • (a) attempt to run make “just like that”:
dcamprof/dcamprof/src$ make                                                             
gcc -o dcamprof.o -c -I. -Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -fopenmp   -DDCAMPROF_VERSION=\"1.0.6\" dcamprof.c
clang: error: unsupported option '-fopenmp'
make: *** [dcamprof.o] Error 1
  • (b) attempt to run make with llvm-gcc, error is the same:
llvm-gcc -o dcamprof.o -c -I. -Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -fopenmp   -DDCAMPROF_VERSION=\"1.0.6\" dcamprof.c
clang: error: unsupported option '-fopenmp'
make: *** [dcamprof.o] Error 1
  • (c) here’s the head of Makefile (and the error output attempt with llvm-clang active?)
INSTALL_PREFIX = /usr/local
DCAMPROF_VERSION = $(shell cat VERSION)
# CC = llvm-gcc
CC = /opt/homebrew/opt/llvm/bin/clang
CFLAGS = -Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -fopenmp
CFLAGS += $(OPTFLAGS)
LDFLAGS = -fopenmp
# LDFLAGS = "-v -L$(brew --prefix llvm)/lib -Wl,-rpath,$(brew --prefix llvm)/lib -L/opt/homebrew/opt/libffi/lib -L/opt/homebrew/opt/expat/lib -L/opt/homebrew/lib -fopenmp"
INCLUDE = -I.
DEFINE =
/opt/homebrew/opt/llvm/bin/clang -o dcamprof.o -c -I. -Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -fopenmp   -DDCAMPROF_VERSION=\"1.0.6\" dcamprof.c
dcamprof.c:7:10: fatal error: 'stdlib.h' file not found
#include <stdlib.h>
         ^~~~~~~~~~
1 error generated.
make: *** [dcamprof.o] Error 1

Not sure which flags I should set so I would be very grateful if anyone could walk me through it.

Thanks very much!

I just did enough research on compiling on the Mac environment to give me shivers…

Someone more familiar will need to help. Now, i did find a Mac OS-X download on Anders’ page, which you may be able to just run:

https://torger.se/anders/dcamprof.html#download

1 Like

Thanks Glenn, I had seen this link but initially discarded it as it was not explicitly mentioning M1 or arm64.

  • I think I have it working (following the much-needed README) : so we have a workaround.
  • Questions pertaining to compilation remain! I’m not sure where to look at, first, if I am to understand which flags I should set and how.

Next: need to acquire a 24-patch target (probably going for a spydercheckr 48 - though it could be overkill and I’m not sure I’m going to be able to use the left half of the chart).
BTW, argyll is available through homebrew.

If you’re just making matrix profiles from target shots, all you really need is the 24-patch ColorChecker; a matrix profile can’t get a lot better than that data. And, dcamprof already has the reference file for it in a format it understands, data-examples/cc24.ref-new.cie

I see. I probably won’t be getting the calibrite colorchecker - I’ve gotten myself an x-rite passport… new old stock from back in 2019 and it’s… lacking the 24-patch card :cry: (for some reason…)

I live in Europe, so SpyderCheckr could be more convenient :smiley:

The reason why I want to do my own DCP is for film negatives.

I think I did it. :slight_smile:

  • note, I use homebrew for the following dependencies:
    • libomp (openmp)
    • libtiff
    • little-cms2

Here’s the mouthful of flags:

export CC="$(which clang)"
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
export CFLAGS="-Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -fopenmp"
export CFLAGS="$CFLAGS -I$(brew --prefix libomp)/include -I$(brew --prefix little-cms2)/include -I$(brew --prefix libtiff)/include $OPTFLAGS"
export LDFLAGS="$LDFLAGS -Wl,-rpath,$(brew --prefix libomp)/lib -L$(brew --prefix libomp)/lib -lomp -L$(brew --prefix little-cms2)/lib -llcms2 -L$(brew --prefix libtiff)/lib -ltiff"

then, from inside the dcamprof/src folder, where the Makefile lies, I:

  • comment out the same flags I’ve just exported in bash,
  • run:
make clean && make
unfold sample compilation output:
/usr/bin/clang -o dcamprof.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" dcamprof.c
/usr/bin/clang -o nmsimplex.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" nmsimplex.c
/usr/bin/clang -o profio.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" profio.c
/usr/bin/clang -o argyllio.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" argyllio.c
/usr/bin/clang -o tps.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" tps.c
/usr/bin/clang -o colmath.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" colmath.c
/usr/bin/clang -o matopt.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" matopt.c
/usr/bin/clang -o lut.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" lut.c
/usr/bin/clang -o lut3d.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" lut3d.c
/usr/bin/clang -o look.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" look.c
/usr/bin/clang -o dngref.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" dngref.c
/usr/bin/clang -o gamut.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" gamut.c
/usr/bin/clang -o spectrum.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" spectrum.c
/usr/bin/clang -o jsonio.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" jsonio.c
/usr/bin/clang -o cJSON.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" cJSON.c
/usr/bin/clang -o interp.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" interp.c
/usr/bin/clang -o bisection.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" bisection.c
/usr/bin/clang -o icclut.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" icclut.c
/usr/bin/clang -o dnglut.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" dnglut.c
/usr/bin/clang -o glare.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" glare.c
/usr/bin/clang -o target.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" target.c
/usr/bin/clang -o xyz2spec.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" xyz2spec.c
/usr/bin/clang -o observers.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" observers.c
/usr/bin/clang -o spectraldb.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" spectraldb.c
/usr/bin/clang -o tifio.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" tifio.c
tifio.c:329:22: warning: 'uint8' is deprecated [-Wdeprecated-declarations]
        static const uint8 prophoto_icc[] =
                     ^
/opt/homebrew/opt/libtiff/include/tiff.h:78:45: note: 'uint8' has been explicitly marked deprecated here
typedef TIFF_MSC_DEPRECATED uint8_t  uint8  TIFF_GCC_DEPRECATED;
                                            ^
/opt/homebrew/opt/libtiff/include/tiff.h:66:44: note: expanded from macro 'TIFF_GCC_DEPRECATED'
#define TIFF_GCC_DEPRECATED __attribute__((deprecated))
                                           ^
1 warning generated.
/usr/bin/clang -o elog.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" elog.c
/usr/bin/clang -o wcompat.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" wcompat.c
/usr/bin/clang -o strbuf.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" strbuf.c
/usr/bin/clang -o spectraldb_munsell.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" spectraldb_munsell.c
/usr/bin/clang -o spectraldb_cc24.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" spectraldb_cc24.c
/usr/bin/clang -o spectraldb_kuopio_natural.o -c -I.  -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" spectraldb_kuopio_natural.c
/usr/bin/clang -o dcamprof  -Wl,-rpath,/opt/homebrew/opt/libomp/lib -L/opt/homebrew/opt/libomp/lib -lomp -L/opt/homebrew/opt/little-cms2/lib -llcms2 -L/opt/homebrew/opt/libtiff/lib -ltiff dcamprof.o nmsimplex.o profio.o argyllio.o tps.o colmath.o matopt.o lut.o lut3d.o look.o dngref.o gamut.o spectrum.o jsonio.o cJSON.o interp.o bisection.o icclut.o dnglut.o glare.o target.o xyz2spec.o observers.o spectraldb.o tifio.o elog.o wcompat.o strbuf.o spectraldb_munsell.o spectraldb_cc24.o spectraldb_kuopio_natural.o -llcms2 -ltiff -lm

I can then happily do ./dcamprof from inside the src folder.

Not sure my flags are perfect or optimised for my m1 mac: actually, I’m quite sure I should change them, but my code compilation skills are mostly non-existant.
Next steps:

  • file a case in the github repo for these guidelines,
  • amend the Makefile to take these Mac flags into account?
1 Like

You have -O2, -fopenmp, and all the libraries, you’re good. Move the executable to one of your bin directories and dcampro to your heart’s content.

Looks like the OMP dependency is one of the things missing from the docs - it’s probably missing because most of the developers already had it installed for other reasons. (dt and RT both use openmp)

Not sure how to handle some of the other Makefile changes without OS-specific makefiles - which is something I have seen before in the past for programs that didn’t use cmake or autoconf

Unfortunately the primary maintainer of that repo has been prone to extended periods of absence without warning lately, so it’s unlikely anyone will get his feedback…

Reviving my own thread. For some reason (obvious suspect: OS upgrades), I can’t compile dcamprof anymore. I would not have needed to do so if it had kept working.
This was the error:
dyld[5313]: Library not loaded: /opt/homebrew/opt/libtiff/lib/libtiff.5.dylib
Indeed, this dylib was upgraded, so the link was missing…
I thought it’d be easy to do the compilation all over again but here I am, complaining.

rm -f dcamprof.o nmsimplex.o profio.o argyllio.o tps.o colmath.o matopt.o lut.o lut3d.o look.o dngref.o gamut.o spectrum.o jsonio.o cJSON.o interp.o bisection.o icclut.o dnglut.o glare.o target.o xyz2spec.o observers.o spectraldb.o tifio.o elog.o wcompat.o strbuf.o spectraldb_munsell.o spectraldb_cc24.o spectraldb_kuopio_natural.o dcamprof
/usr/bin/clang -o dcamprof.o -c -I. -Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -fopenmp -I/opt/homebrew/opt/libomp/include -I/opt/homebrew/opt/little-cms2/include -I/opt/homebrew/opt/libtiff/include   -DDCAMPROF_VERSION=\"1.0.6\" dcamprof.c
clang: error: unsupported option '-fopenmp'
make: *** [dcamprof.o] Error 1

:frowning:

You are either missing the openmp extension/library for clang or openmp isn’t supported and you need to remove that flag from your compile command.

Seems like something homebrew should handle for you, but I never got on well with homebrew.

Well I am not well versed enough when it comes to compilation anyway, be it with cmake or make, no matter the environment. I suppose something must be wrong with the way I set flags as I haven’t removed openmp or anything required either by rawtherapee or dcamprof. Also, I read here and there I should perhaps try llvm instead but I haven’t been successful either. I would be surprised if it had to do with something else than my own inexperience with flags and various options.

in an macports environment use:

CFLAGS = -Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -fopenmp-version=45
CFLAGS += $(OPTFLAGS)
LDFLAGS = -fopenmp-version=45 -L/opt/local/lib/libomp -L/opt/local/lib/
INCLUDE = -I. -I/opt/local/include/libomp -I/opt/local/include

requires ports tiff, lcms2 and libomp

1 Like

Got it to work again! I was inspired with what you mentioned to try again my luck directly in the Makefile itself.

This is how mine looks now:

CC = /usr/bin/clang
CFLAGS = -Wall -std=c99 -g -O2 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -Xpreprocessor -fopenmp
CFLAGS += $(OPTFLAGS)
LDFLAGS = -lomp -L/opt/homebrew/opt/libomp/lib -L/opt/homebrew/lib/
INCLUDE = -I. -I/opt/homebrew/opt/libomp/include/ -I/opt/homebrew/include
DEFINE =

→ to use -fopenmp in the CFLAGS, -Xpreprocessor is required
→ to use libomp in the LDFLAGS, -lomp is required.

So it’s solved again :smiley:
EDIT: I’ve updated the bug filed in the dcamprof repository as well

2 Likes