jcelaya / hdrmerge

HDR exposure merging
http://jcelaya.github.io/hdrmerge/
Other
355 stars 78 forks source link

Fix compilation using exiv2-0.27 #172

Closed Beep6581 closed 5 years ago

Beep6581 commented 5 years ago

Compilation is currently broken on the configuration stage when using exiv2-0.27.

Patch from @darix https://build.opensuse.org/package/rdiff/home:darix:playground/hdrmerge?linkrev=base&rev=5

darix commented 5 years ago

my patch cleans up the whole thing quite radically by either relying on the exiv2 own exiv2Config.cmake or pkg_check_module (for libraw) ... instead of using the whole indirection.

fanckush commented 5 years ago

Any quick workaround till the fix is implemented?

Beep6581 commented 5 years ago

I created branch cmake-exiv2 using the patch from @darix and can confirm that it fixes compilation in Sabayon using exiv2-0.27.0.

@heckflosse @Floessie @fanckush please test, then I will merge.

fanckush commented 5 years ago

Just tested on macOS 10.14.4 and sure enough it fixed the completion error when using exiv2 v0.27 Thanks

fanckush commented 5 years ago

I'd like to add that I get the following error. tho I'm not sure it's related

[ 53%] Building CXX object CMakeFiles/hdrmerge.dir/src/Launcher.cpp.o
/Users/imad/hdrmerge/src/main.cpp:23:10: fatal error: 'exiv2/error.hpp' file not found
#include <exiv2/error.hpp>
         ^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/hdrmerge.dir/src/main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/hdrmerge.dir/all] Error 2
make: *** [all] Error 2
heckflosse commented 5 years ago

@Beep6581 I never managed to build hdrmerge on Windows.

darix commented 5 years ago

include <exiv2/error.hpp>

could be that file was removed in the exiv2 release. maybe you can still access all the types/function definition that used to be in the error.hpp if you just include the base exiv2 headers?

Beep6581 commented 5 years ago

I have media-gfx/exiv2-0.27.0-r2 installed and there is a file /usr/include/exiv2/error.hpp

fanckush commented 5 years ago

when I try to rerun sudo make -j4 install then I get a similar error for #include <exiv2/exiv2.hpp> I checked and I have all the headers here /usr/local/Cellar/exiv2/0.27.0a/include/exiv2

Either I'm doing something wrong along the way. or Cmake is not finding the include dir

Beep6581 commented 5 years ago

@fanckush and you're compiling in a clean, out-of-source build folder?

Benitoite commented 5 years ago

@darix @Beep6581 On system MacOS 10.14.5ß18F118d, cmake-exiv2 branch, latest cmake, this is what I get:

-- Found PkgConfig: /opt/local/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'libraw'
--   Found libraw, version 0.17.2
-- Checking for module 'libraw_r'
--   Found libraw_r, version 0.17.2

...

[100%] Linking CXX executable hdrmerge.app/Contents/MacOS/hdrmerge
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/hdrmerge.dir/link.txt --verbose=1
/usr/bin/clang++   -std=c++11 -Wall -Wno-unknown-pragmas -Xpreprocessor -fopenmp /opt/local/lib/libiomp5.dylib -I/opt/local/include -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/hdrmerge.dir/hdrmerge_autogen/mocs_compilation.cpp.o CMakeFiles/hdrmerge.dir/src/main.cpp.o CMakeFiles/hdrmerge.dir/src/Launcher.cpp.o CMakeFiles/hdrmerge.dir/src/Image.cpp.o CMakeFiles/hdrmerge.dir/src/ImageStack.cpp.o CMakeFiles/hdrmerge.dir/src/Bitmap.cpp.o CMakeFiles/hdrmerge.dir/src/RawParameters.cpp.o CMakeFiles/hdrmerge.dir/src/EditableMask.cpp.o CMakeFiles/hdrmerge.dir/src/DngFloatWriter.cpp.o CMakeFiles/hdrmerge.dir/src/TiffDirectory.cpp.o CMakeFiles/hdrmerge.dir/src/BoxBlur.cpp.o CMakeFiles/hdrmerge.dir/src/ExifTransfer.cpp.o CMakeFiles/hdrmerge.dir/src/ImageIO.cpp.o CMakeFiles/hdrmerge.dir/src/AboutDialog.cpp.o CMakeFiles/hdrmerge.dir/src/MainWindow.cpp.o CMakeFiles/hdrmerge.dir/src/PreviewWidget.cpp.o CMakeFiles/hdrmerge.dir/src/DraggableScrollArea.cpp.o CMakeFiles/hdrmerge.dir/src/DngPropertiesDialog.cpp.o CMakeFiles/hdrmerge.dir/src/LoadOptionsDialog.cpp.o CMakeFiles/hdrmerge.dir/src/FileSystem.cpp.o CMakeFiles/hdrmerge.dir/hdrmerge_autogen/QYFM2Z2WYQ/qrc_resources.cpp.o CMakeFiles/alglib-objects.dir/alglib-objects_autogen/mocs_compilation.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/alglibinternal.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/alglibmisc.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/ap.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/dataanalysis.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/diffequations.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/fasttransforms.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/integration.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/interpolation.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/linalg.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/optimization.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/solvers.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/specialfunctions.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/statistics.cpp.o  -o hdrmerge.app/Contents/MacOS/hdrmerge -Wl,-rpath,/Users/rb/Qt596/5.9.6/clang_64/lib -lraw_r -lstdc++ -llcms2 /opt/local/lib/libz.dylib /Users/rb/Qt596/5.9.6/clang_64/lib/QtWidgets.framework/QtWidgets -lexiv2 /Users/rb/Qt596/5.9.6/clang_64/lib/QtGui.framework/QtGui /Users/rb/Qt596/5.9.6/clang_64/lib/QtCore.framework/QtCore 
ld: library not found for -lraw_r
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [hdrmerge.app/Contents/MacOS/hdrmerge] Error 1
make[1]: *** [CMakeFiles/hdrmerge.dir/all] Error 2
make: *** [all] Error 2
$  ls -la /opt/local/lib/libraw*
-rwxr-xr-x  1 root  wheel  1141440 Apr 25 08:38 /opt/local/lib/libraw.15.dylib
-rw-r--r--  1 root  wheel  1284232 Apr 25 08:38 /opt/local/lib/libraw.a
lrwxr-xr-x  1 root  wheel       15 Apr 25 08:38 /opt/local/lib/libraw.dylib -> libraw.15.dylib
-rwxr-xr-x  1 root  wheel      998 Apr 25 08:38 /opt/local/lib/libraw.la
-rwxr-xr-x  1 root  wheel  1141440 Apr 25 08:38 /opt/local/lib/libraw_r.15.dylib
-rw-r--r--  1 root  wheel  1284232 Apr 25 08:38 /opt/local/lib/libraw_r.a
lrwxr-xr-x  1 root  wheel       17 Apr 25 08:38 /opt/local/lib/libraw_r.dylib -> libraw_r.15.dylib
-rwxr-xr-x  1 root  wheel     1010 Apr 25 08:38 /opt/local/lib/libraw_r.la
$ cat /opt/local/lib/pkgconfig/libraw_r.pc
prefix=/opt/local
exec_prefix=${prefix}
libdir=/opt/local/lib
includedir=${prefix}/include

Name: libraw
Description: Raw image decoder library (thread-safe)
Requires: lcms2
Version: 0.17.2
Libs: -L${libdir} -lraw_r -lstdc++
Cflags: -I${includedir}/libraw

Also, exiv2, a similar prob.

[100%] Linking CXX executable hdrmerge.app/Contents/MacOS/hdrmerge
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/hdrmerge.dir/link.txt --verbose=1
/usr/bin/clang++   -std=c++11 -Wall -Wno-unknown-pragmas -Xpreprocessor -fopenmp /opt/local/lib/libiomp5.dylib -I/opt/local/include -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/hdrmerge.dir/hdrmerge_autogen/mocs_compilation.cpp.o CMakeFiles/hdrmerge.dir/src/main.cpp.o CMakeFiles/hdrmerge.dir/src/Launcher.cpp.o CMakeFiles/hdrmerge.dir/src/Image.cpp.o CMakeFiles/hdrmerge.dir/src/ImageStack.cpp.o CMakeFiles/hdrmerge.dir/src/Bitmap.cpp.o CMakeFiles/hdrmerge.dir/src/RawParameters.cpp.o CMakeFiles/hdrmerge.dir/src/EditableMask.cpp.o CMakeFiles/hdrmerge.dir/src/DngFloatWriter.cpp.o CMakeFiles/hdrmerge.dir/src/TiffDirectory.cpp.o CMakeFiles/hdrmerge.dir/src/BoxBlur.cpp.o CMakeFiles/hdrmerge.dir/src/ExifTransfer.cpp.o CMakeFiles/hdrmerge.dir/src/ImageIO.cpp.o CMakeFiles/hdrmerge.dir/src/AboutDialog.cpp.o CMakeFiles/hdrmerge.dir/src/MainWindow.cpp.o CMakeFiles/hdrmerge.dir/src/PreviewWidget.cpp.o CMakeFiles/hdrmerge.dir/src/DraggableScrollArea.cpp.o CMakeFiles/hdrmerge.dir/src/DngPropertiesDialog.cpp.o CMakeFiles/hdrmerge.dir/src/LoadOptionsDialog.cpp.o CMakeFiles/hdrmerge.dir/src/FileSystem.cpp.o CMakeFiles/hdrmerge.dir/hdrmerge_autogen/QYFM2Z2WYQ/qrc_resources.cpp.o CMakeFiles/alglib-objects.dir/alglib-objects_autogen/mocs_compilation.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/alglibinternal.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/alglibmisc.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/ap.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/dataanalysis.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/diffequations.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/fasttransforms.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/integration.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/interpolation.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/linalg.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/optimization.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/solvers.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/specialfunctions.cpp.o CMakeFiles/alglib-objects.dir/Users/rb/alglib/cpp/src/statistics.cpp.o  -o hdrmerge.app/Contents/MacOS/hdrmerge -Wl,-rpath,/Users/rb/Qt596/5.9.6/clang_64/lib /opt/local/lib/libraw_r.dylib /opt/local/lib/libz.dylib /Users/rb/Qt596/5.9.6/clang_64/lib/QtWidgets.framework/QtWidgets -lexiv2 /Users/rb/Qt596/5.9.6/clang_64/lib/QtGui.framework/QtGui /Users/rb/Qt596/5.9.6/clang_64/lib/QtCore.framework/QtCore 
ld: library not found for -lexiv2

To enable compilation, I hardcoded the libs:

$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a5fead..aed612b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,7 +187,7 @@ endif()

 # Libs
 set(hdrmerge_libs
-    "${LibRaw_r_LIBRARIES}"
+    "/opt/local/lib/libraw_r.dylib"
     "${exiv2_LIBRARIES}"
     "${ZLIB_LIBRARIES}"
 )
@@ -274,7 +274,7 @@ else()
     )
 endif()

-target_link_libraries(hdrmerge ${STRIP} ${hdrmerge_libs} Qt5::Widgets exiv2)
+target_link_libraries(hdrmerge ${STRIP} ${hdrmerge_libs} Qt5::Widgets /opt/local/lib/libexiv2.dylib)

 if(WIN32)
     # Compile a target without GUI, for the .com executable
darix commented 5 years ago

please provide the output of

pkg-config --libs libraw_r

because to me it looks like your pkg-config file for libraw_r is broken.

for exiv2 ... check exiv2Config*.cmake

and maybe compare it to:

pkg-config --libs exiv2

I would not want to add work around for broken data files in the cmakelists.txt if the real fix should go into the packages on your OSX.

fanckush commented 5 years ago

@Benitoite do you have OS X 10.9? if not you should change the part where you specify the SDK "..../MacOSX10.9.sdk...."

@Beep6581 yes I am. I will get back to you once I try on a (friend's) clean macOS installation to eliminate the chances of me messing something up regarding exiv2 libs

Benitoite commented 5 years ago

@darix

$ pkg-config --libs libraw_r
-L/opt/local/lib -lraw_r -lstdc++ -llcms2

and

$ pkg-config --libs exiv2
-L/opt/local/lib -lexiv2

and /opt/local/lib/exiv2/cmake things are all latest libexiv2.0.27.1.1.

@fanckush I build for 10.9+.

darix commented 5 years ago

both look correct. If the -l... normally works on osx. if not ... then your pkgconfig files should return to the dylib file

for the cmake files ... check that the paths in those files are correct too.

Benitoite commented 5 years ago

-l does normally work, and -lexiv2 & -lraw_r have worked elsewhere. The lib/exiv2/cmake/things use an _IMPORT_PREFIX for the path. It seems right? libexpat.dylib path is hardcoded by the generation. I tested compilation on LuminanceHDR using the same exiv2 and libraw_r and there was no problemo.

fanckush commented 5 years ago

@Benitoite oh that works, however if I'm not mistaken, the CMAKE_OSX_DEPLOYMENT_TARGET allows you to use the latest SDK and still support older macOS versions.. that's not related to this issue but thought to mention it.

@Beep6581 I got the same issue on a fresh macOS installation. hardcoding the include dir for exiv2:

include_directories(
    "${LibRaw_INCLUDE_DIRS}"
    # exiv2
    "hardcoded/include/path/here"
    "${ZLIB_INCLUDE_DIRS}"
    "${ALGLIB_INCLUDES}"
)

I ended up pretty much with the issues that Benitoite had, and so I followed what he did to make it compile

darix commented 5 years ago

if you are adding back hardcoded things to the hdrmerge files you are fixing the wrong things. the new code for building asks your system "hey tell us where to find the headers and how to link this library" and your system tells us wrong things.

Benitoite commented 5 years ago

My question then is why does the linker not know where to find those two libs? Instead of hardcoding paths into CMakeLists.txt, we could pass the libs thru the cmake invocation.

fanckush commented 5 years ago

I'm not suggesting to hardcode the paths of course. Anyway, as a different approach, I switched to master and changed this:

diff --git a/cmake/FindExiv2.cmake b/cmake/FindExiv2.cmake
index f929269..e9b463c 100644
--- a/cmake/FindExiv2.cmake
+++ b/cmake/FindExiv2.cmake
@@ -73,7 +73,7 @@ endif(EXIV2_INCLUDE_DIR  AND NOT  EXIV2_VERSION)
 set(EXIV2_LIBRARIES "${EXIV2_LIBRARY}")

 include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Exiv2  REQUIRED_VARS  EXIV2_LIBRARY EXIV2_INCLUDE_DIR
+find_package_handle_standard_args(exiv2  REQUIRED_VARS  EXIV2_LIBRARY EXIV2_INCLUDE_DIR
                                          VERSION_VAR  EXIV2_VERSION)

 mark_as_advanced(EXIV2_INCLUDE_DIR EXIV2_LIBRARY)

and it builds. can someone test this? and point out possible issues of doing this as well?

Benitoite commented 5 years ago

@fanckush That change also configures for me (sans version error). What I was experimenting with was making the minimum version requirement for exiv2 be ".." instead of "0.12" which also configured ok. @clanmills on the exiv2 team might be able to shed some light.

Beep6581 commented 5 years ago

Currently, master fails with:

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Exiv2: Found unsuitable version "..", but required is at
  least "0.12" (found /usr/lib64/libexiv2.so)

I confirm that @fanckush 's patch fixes compilation in master using exiv2-0.27.0. It produces:

-- Found exiv2: /usr/lib64/libexiv2.so (found version "..")

How do we proceed - just apply @fanckush 's patch, or merge PR #174?

Beep6581 commented 5 years ago

@fanckush to clarify, you do not end up with a successful build on macOS 10.14.4 using branch cmake-exiv2, but you do when using your patch alone, is that correct?

Beep6581 commented 5 years ago

Ping @darix

Benitoite commented 5 years ago

@Beep6581

The @fanckush patch on master works for me (MacOS 10.14.5ß18F127a).

cmake-exiv2 is not yet working on mac (I had to hardcode the paths of libraw_r and exiv2 into CMakeLists.txt)

cryptomilk commented 5 years ago

Can someone try https://xor.cryptomilk.org/FindExiv2.cmake

Benitoite commented 5 years ago

@cryptomilk Thanks Andreas, works on mac for me, except you need to comment out line 49 😄

fanckush commented 5 years ago

@Beep6581

CMake Error at /usr/local/Cellar/cmake/3.14.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Exiv2: Found unsuitable version "..", but required is at
  least "0.12" (found /usr/local/Cellar/exiv2/0.27.0a/lib/libexiv2.dylib)

However, make install fails for unrelated reason caused by /usr/local/include/ not being used macOS: /usr/local/include not a system include directory under CMake the sepecfic error I got:

/usr/local/Cellar/exiv2/0.27.0a/include/exiv2/ssh.hpp:27:10: fatal error: 
      'libssh/libssh.h' file not found
#include <libssh/libssh.h>
         ^~~~~~~~~~~~~~~~~

in this case libssh can be found in /usr/local/include/

fanckush commented 5 years ago

@cryptomilk This worked like a charm! it also fixed my /usr/local/include/ issue @Beep6581 ignore my previous comment :)

Beep6581 commented 5 years ago

@cryptomilk I confirm that using your patch it compiles and runs well in Sabayon Linux

-- Checking for module 'exiv2'
--   Found exiv2, version 0.27.0
-- Found Exiv2: /usr/include (found version "..")
Beep6581 commented 5 years ago

I will merge PR #177 tonight if noone objects.