MacOSX build of Luminance_HDR_2.5.1

Thanks @fcomida for the great help with the Macintosh compilation!
Thanks @clanmills for your generous help with the macintosh packaging!

https://filebin.net/2djmoa4x4sf6r6nc/Luminance_HDR_2.5.1.dmg

Good News. Great Job, @HIRAM
I’ve downloaded and installed your DMG and it’s working, with one little glitch. And here’s the fix.

Initially, it refused to run with the error:

Dyld Error Message:
  Library not loaded: /usr/local/Cellar/fftw/3.3.6-pl1/lib/libfftw3f.3.dylib
  Referenced from: /Applications/Luminance HDR 2.5.1.app/Contents/Frameworks/libfftw3f_threads.3.dylib
  Reason: image not found

I played with DYLD_PRINT_LIBRARIES and otool -L and install_name and everything seems fine. So I copied your library into /usr/local/lib and Luminance started:

533 rmills@rmillsmbp:/Applications/Luminance HDR 2.5.1.app $ sudo cp Contents/Frameworks/libfftw3f.3.dylib /usr/local/lib/

This is being caused by Contents/Frameworks/libfftw3f_threads.3.dylib:

@executable_path/../Frameworks/libfftw3f_threads.3.dylib (compatibility version 9.0.0, current version 9.6.0)
/usr/local/Cellar/fftw/3.3.6-pl1/lib/libfftw3f.3.dylib (compatibility version 9.0.0, current version 9.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

549 rmills@rmillsmbp:/Applications/Luminance HDR 2.5.1.app $

You can fix that with install_name_tool:

554 rmills@rmillsmbp:/Applications/Luminance HDR 2.5.1.app $ install_name_tool -change /usr/local/Cellar/fftw/3.3.6-pl1/lib/libfftw3f.3.dylib @executable_path/../Frameworks/libfftw3f.3.dylib Contents/Frameworks/libfftw3f_threads.3.dylib

I’m very pleased that you have this built. Thanks to @fcomida, I now have access to the Luminance GitHub repos. I didn’t have much time today, however I wasn’t able to build anything as I only appear to have access to LibHDR.

I’d like to discuss is who will maintain Luminance on MacOSX in the future? I’m happy to get involved in a limited way. I’m the Principal Contributor to Exiv2 and that keeps me busy. If you’re willing to own maintencance Luminance/Mac, I’d be happy to help you with that task.

I’m not sure when/where I should invoke the command… in order to fix the app generated inside the dmg. I see you are in /Applications/Luminance HDR 2.5.1.app.

I’d be happy to keep building for the Mac, with your help, and thanks for helping btw!

Together we can easily fix this. Can we talk on Skype “clanmills”?

Yes, Robin, my Skype is Barber408. Thx.

Thanks. I’ve left the following message on Skype:

You can use that command at the end of the build and before you move the app into the DMG. However that’s a repair to libfftw3f_threads.3.dylib to get it load Frameworks/libfftw3f.3.dylib. The “real” build issue is in Contents/Frameworks/libfftw3f_threads.3.dylib being linked to /usr/local/Cellar/fftw/3.3.6-pl1/lib/libfftw3f.3.dylib

You can inspect the linking table in any library or executable with the command:

$ otool -L Contents/Framework/foo.dylib

I haven’t built Luminance yet, as I only joined the team on Tuesday. You should investigate how libfftw3f_threads.3.dylib is built and fix it there. However, if it arrives as a binary from somewhere, using install_name_tool to fix the linking table in libfftw3f_threads.3.dylib is fine.

I’m seeing the issue more clearly now… cmake is not finding fftw 3.3.5 from macports but will find 3.3.6 installed by brew. Do you think that could be a culprit?

I’ve made good (and slow/painful) progress with building this from source. I’ve got it working with four unpleasant matters:

  1. $ cmake … -G “Unix Makefiles” -DCMAKE_PREFIX_PATH=/Users/rmills/Qt/5.8/clang_64/lib/cmake/
    I need this to persuade cmake to find Qt .cmake files which are used to find headers and libraries

  2. It won’t start with the cryptic message:
    735 rmills@rmillsmbp:/Applications/Luminance HDR 2.5.1.app $ Contents/MacOS/Luminance\ HDR\ 2.5.1
    This application failed to start because it could not find or load the Qt platform plugin “cocoa”
    in “”.

Reinstalling the application may fix this problem.
Abort trap: 6

I copied in the PlugIns from your build and then it started:
ditto ditto PlugIns/ ~/gnu/git/LuminanceHDR/build/Luminance\ HDR\ 2.5.1.app/Contents/PlugIns 736 18:44:32 history | grep ditto 737 rmills@rmillsmbp:/Applications/Luminance HDR 2.5.1.app

  1. The linking is a mess. Your build was beautifully linked with @loader_path/…/Frameworks. So, the user doesn’t need to install Qt, you are shipping the subset of Qt required by your App. And your app is immune to changes made by Qt. Every user is using the libraries that you ship. So your App is fatter, however your App is complete and self contained.

  2. Asking CMake to generate Xcode files results in compilation errors. I built with -G “Unix Makefiles”.

All of this can be fixed without much difficulty. However before I continue to work on this, I’d like to hear your thoughts and everything.

It’s taken most of today (Thursday) to make this progress. Most of that was spent attempting to built fftw from source. In the end I built fink and used him to build fftw3.


I noticed CalTrain on your Facebook Page. Alison and I lived in San Jose for 14 years before we retired to our “old” home in England in 2014. We’re happy to be home and seldom miss California. We’re looking forward to a trip to California in October to catch up with our friends and haunts.

@HIRAM drop me an email, we’ll further discuss your involvement with the project.

You can fix that with install_name_tool:

554 rmills@rmillsmbp:/Applications/Luminance HDR 2.5.1.app $ install_name_tool -change /usr/local/Cellar/fftw/3.3.6-pl1/lib/libfftw3f.3.dylib @executable_path/../Frameworks/libfftw3f.3.dylib Contents/Frameworks/libfftw3f_threads.3.dylib

Ok, what I’ve done is modify my create-dmg.sh to comment out the rm *app and make install commands. That way, I can sudo make install before creating the dmg, and apply the install_name_tool fix in the installed app framework. The I ran create-dmg.sh which packaged the fixed app from its installation in /applications. Theoretically now it should work I think.

One thing I’m sensing is the brew fftw is to blame for this error… I attempted to compile fftw3 from source, but configure balked at the gfortran compiler I have installed right now. I think it prefers g77?

checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... gfortran
checking whether we are using the GNU Fortran 77 compiler... no
checking whether gfortran accepts -g... no
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for gfortran option to produce PIC... 
checking if gfortran static flag  works... no
checking if gfortran supports -c -o file.o... no
checking if gfortran supports -c -o file.o... (cached) no
checking whether the gfortran linker (/opt/local/libexec/llvm-3.9/bin/ld) supports shared libraries... no
checking dynamic linker characteristics... darwin16.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking how to get verbose linking output from gfortran... configure: WARNING: compilation failed

checking for Fortran 77 libraries of gfortran... 
checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... configure: error: in `/Users/tune/Downloads/fftw-3.3.5':
configure: error: cannot compile a simple Fortran program
See `config.log' for more details 

And the relevant part of config.log…

configure:16938: checking for gfortran
configure:16954: found /usr/local/bin/gfortran
configure:16965: result: gfortran
configure:16991: checking for Fortran 77 compiler version
configure:17000: gfortran --version >&5
GNU Fortran (GCC) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:17011: $? = 0
configure:17000: gfortran -v >&5
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin16/6.3.0/lto-wrapper
Target: x86_64-apple-darwin16
Configured with: ../gcc-6.3.0/configure --prefix=/usr/local/gfortran --enable-languages=c,c++,fortran,objc,obj-c++ --build=x86_64-apple-darwin16 --with-gmp=/Users/fx/devel/gcc/deps-static/x86_64 --with-mpfr=/Users/fx/devel/gcc/deps-static/x86_64 --with-mpc=/Users/fx/devel/gcc/deps-static/x86_64 --with-isl=/Users/fx/devel/gcc/deps-static/x86_64
Thread model: posix
gcc version 6.3.0 (GCC) 
configure:17011: $? = 0
configure:17000: gfortran -V >&5
gfortran: error: unrecognized command line option '-V'
gfortran: fatal error: no input files
compilation terminated.
configure:17011: $? = 1
configure:17000: gfortran -qversion >&5
gfortran: error: unrecognized command line option '-qversion'; did you mean '--version'?
gfortran: fatal error: no input files
compilation terminated.
configure:17011: $? = 1
configure:17020: checking whether we are using the GNU Fortran 77 compiler
configure:17033: gfortran -c  conftest.F >&5
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
configure:17033: $? = 1
configure: failed program was:
|       program main
| #ifndef __GNUC__
|        choke me
| #endif
| 
|       end
configure:17042: result: no
configure:17048: checking whether gfortran accepts -g
configure:17059: gfortran -c -g conftest.f >&5
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
configure:17059: $? = 1
configure: failed program was:
|       program main
| 
|       end
configure:17067: result: no
configure:17203: checking if libtool supports shared libraries
configure:17205: result: yes
configure:17208: checking whether to build shared libraries
configure:17228: result: no
configure:17231: checking whether to build static libraries
configure:17235: result: yes
configure:17556: checking for gfortran option to produce PIC
configure:17563: result: 
configure:17629: checking if gfortran static flag  works
configure:17657: result: no
configure:17669: checking if gfortran supports -c -o file.o
configure:17690: gfortran -c  -o out/conftest2.o conftest.f >&5
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
configure:17694: $? = 1
configure:17716: result: no
configure:17721: checking if gfortran supports -c -o file.o
configure:17768: result: no
configure:17798: checking whether the gfortran linker (/opt/local/libexec/llvm-3.9/bin/ld) supports shared libraries
configure:18905: result: no
configure:19046: checking dynamic linker characteristics
configure:19708: result: darwin16.5.0 dyld
configure:19761: checking how to hardcode library paths into programs
configure:19786: result: immediate
configure:19828: checking how to get verbose linking output from gfortran
configure:19838: gfortran -c  conftest.f >&5
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
configure:19838: $? = 1
configure: failed program was:
|       program main
| 
|       end
configure:19933: WARNING: compilation failed
configure:19939: result: 
configure:19941: checking for Fortran 77 libraries of gfortran
configure:19964: gfortran -o conftest conftest.f -lm
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
configure:20160: result: 
configure:20176: checking for dummy main to link with Fortran 77 libraries
configure:20210: /opt/local/libexec/llvm-3.9/bin/clang -o conftest -arch x86_64   conftest.c -lm   >&5
configure:20210: $? = 0
configure:20255: result: none
configure:20295: checking for Fortran 77 name-mangling scheme
configure:20308: gfortran -c  conftest.f >&5
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
configure:20308: $? = 1
configure: failed program was:
|       subroutine foobar()
|       return
|       end
|       subroutine foo_bar()
|       return
|       end
configure:20441: error: in `/Users/tune/Downloads/fftw-3.3.5':
configure:20443: error: cannot compile a simple Fortran program
See `config.log' for more details

@HIRAM pass this options to configure: --disable-fortran --enable-openmp

Thanks @fcomida, configures, builds and installs fine now, but cmake in lhdr still refuses to find it. Maybe I’m not passing it’s directory properly? Also, since it’s specified in the INSTALL instructions that we need the fp fftw I’m also passing the --enable-single flag to configure. Is that accurate?

CMake Error at build_files/Modules/Findfftwf.cmake:44 (MESSAGE):
  Could not find FFTW3F
Call Stack (most recent call first):
  CMakeLists.txt:107 (FIND_PACKAGE)

Also I’m trying getting fftw3 from fink, cmake does find this as it did the brew version.

With the fink’s fftw3, here’s what otool has to say about the .dylib we’ve been having trouble with…

otool -L /Applications/Luminance\ HDR\ 2.5.1.app/Contents/Frameworks/libfftw3f_threads.3.dylib 
/Applications/Luminance HDR 2.5.1.app/Contents/Frameworks/libfftw3f_threads.3.dylib:
	@executable_path/../Frameworks/libfftw3f_threads.3.dylib (compatibility version 9.0.0, current version 9.6.0)
	@loader_path/libfftw3f.3.dylib (compatibility version 9.0.0, current version 9.6.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.51.1)
	@loader_path/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

Seems like it should load clean to me…?

@HIRAM That Findfftwf.cmake looks very linux-centric to me. You can add more paths in the SET(TRIAL_PATHS…). and SET(TRIAL_LIBRARY_PATHS…) sections. --enable-single flag is correct.

@HIRAM Very good job indeed. Congratulations. Installs flawlessly on both my Macs. The Exiv2 buildserver (a Mac Mini) does not have Qt installed and your build is running perfectly on that machine.

We could work together to actually build Luminance on the buildserver and folks can download it directly from there.

1 Like

About Findfftwf.cmake. I modified my copy yesterday. I don’t know if that made any difference. I added /opt/local and /sw/lib

SET(TRIAL_PATHS
  $ENV{FFTWF_HOME}/include
  /usr/include
  /usr/local/include
  /opt/include
  /usr/apps/include
  /opt/local
)

SET(TRIAL_LIBRARY_PATHS
  $ENV{FFTWF_HOME}/lib
  /usr/lib
  /usr/local/lib
  /opt/lib
  /sw/lib
  /opt/local
  )