Make dcamprof work - macOS

I want to use dcamprof to convert ICC to DCP and vice versa.

According to its README, the included library must be manually linked. I do this from my home dir:

install_name_tool -change /usr/local/lib/libomp.dylib ~/libraries/dcamprof-1.0.6-macosx/libomp.dylib ~/libraries/dcamprof-1.0.6-macosx/dcamprof

The dcamprof command works from ~, but as soon as I change the directory, I get the old error:

dyld: Library not loaded: libraries/dcamprof-1.0.6-macosx/libomp.dylib Referenced from: /Users/andi/libraries/dcamprof-1.0.6-macosx/dcamprof Reason: image not found Trace/BPT trap: 5

I have no knowledge about install_name_tool . How can I change the link globally, so that dcamprof works everywhere?

The easy way to do it is to copy libomp.dylib into /usr/local/lib. Then the dcamprof binary will work from anywhere.

Your install_name_tool invocation should also work, but from the error message I would say you missed the ~/ off the new library path. If you want to try again, its easier if you start with a fresh copy of dcamprof, as install_name_tool only changes the exact library path you specifiy and will fail silently otherwise.
You can use otool -L dcamprof to see the library paths it is currently using.

I still don’t understand the syntax. I included the ~, so it’s an absolute path and should work anywhere.
However, I have just copied the lib into /usr/local/lib and it works. Symbolic linking is not sufficient.

Thank you.

If I list the dynamic libraries that dcamprof is currently linked against I get this:

otool -L dcamprof
dcamprof:
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/local/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

When you launch dcamprof, the loader will look for libraries at those locations, if it finds them it will use them, otherwise it searches for the library on the library search path.

install_name_tool lets you edit the library paths in the dcamprof executable.

The syntax is:
install_name_tool -change <<current lib path>> <<new lib path>> dcamprof

Which means “change the library reference in dcamprof that currently points to <<current path>> so that it points to <<new path>> instead”.

The current path must be one of the ones that otool -L lists (otherwise the change is ignored), the new path points to wherever the library should be. You can set it to a relative path, but that isn’t very useful in practice because the path is interpreted as relative to the current working directory when dcamprof is run. There is an option that is more useful - if you set the path to something that starts with @executable_path/ then that path is relative to the location of the dcamprof executable (wherever it may be).
There are also some limits on the length of the path you can set it to, which will depend on the options that were used to link dcamprof in the first place.

So:

install_name_tool -change /usr/local/lib/libomp.dylib @executable_path/libomp.dylib dcamprof

will make dcamprof look for libomp.dylib in the same directory as dcamprof itself.

Running otool again after the above install_name_tool command will show the new library paths:

dcamprof:
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	@executable_path/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

Does that make it any clearer?

Yes, thanks for the details. But it didn’t work that way. Probably there is a problem with my binary.

otool -L dcamprof shows:

/opt/local/libexec/llvm-5.0/bin/llvm-objdump: 'dcamprof': No such file or directory fatal error: otool: internal objdump command failed

Anyway, dcamprof works now.