vera icon indicating copy to clipboard operation
vera copied to clipboard

Exiv2 build error

Open jnsh opened this issue 1 year ago • 3 comments

Building vera (as submodule for glslviewer) fails with the following error:

[ 50%] Building CXX object deps/vera/src/CMakeFiles/vera.dir/gl/texture.cpp.o
/home/joonas/builds/glslviewer-git/src/glslviewer/deps/vera/src/gl/defines.cpp: In member function ‘virtual void vera::HaveDefines::addDefinesTo(const std::string&)’:
/home/joonas/builds/glslviewer-git/src/glslviewer/deps/vera/src/gl/defines.cpp:106:19: error: ‘AutoPtr’ is not a member of ‘Exiv2::Image’
  106 |     Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(_path);
      |                   ^~~~~~~
In file included from /usr/include/c++/13.2.1/cassert:44,
                 from /usr/include/exiv2/slice.hpp:6,
                 from /usr/include/exiv2/types.hpp:10,
                 from /usr/include/exiv2/basicio.hpp:11,
                 from /usr/include/exiv2/exiv2.hpp:8,
                 from /home/joonas/builds/glslviewer-git/src/glslviewer/deps/vera/src/gl/defines.cpp:5:
/home/joonas/builds/glslviewer-git/src/glslviewer/deps/vera/src/gl/defines.cpp:107:12: error: ‘image’ was not declared in this scope
  107 |     assert(image.get() != 0);
      |            ^~~~~
make[2]: *** [deps/vera/src/CMakeFiles/vera.dir/build.make:244: deps/vera/src/CMakeFiles/vera.dir/gl/defines.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:277: deps/vera/src/CMakeFiles/vera.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/home/joonas/builds/glslviewer-git/src/build'

This happens on Arch linux with exiv2-0.28.1.

jnsh avatar Dec 17 '23 12:12 jnsh

Sorry for that, I'm commenting the inclusion of exiv2 in the CMakeLists file. If you figure any solution rather than it, please submit a PR

patriciogonzalezvivo avatar Dec 17 '23 21:12 patriciogonzalezvivo

Looks like it's this change in exiv2 since 0.28.0 should be related: https://github.com/Exiv2/exiv2/commit/0bbaa6eff3c93dfc5242af4069ccff56f48ba5fb

Maybe simply replacing AutoPtr with UniquePtr when compiling against newer exiv2 could be enough? I don't have time to test it right now, and either way don't understand the code or the exiv2 change well enough to know for sure whether this would be the proper fix.

jnsh avatar Dec 17 '23 22:12 jnsh

This fixes the defines.cpp compilation with exiv2 0.28.1:

--- a/src/gl/defines.cpp
+++ b/src/gl/defines.cpp
@@ -103,7 +103,7 @@ void HaveDefines::printDefines() {
 
 void HaveDefines::addDefinesTo( const std::string &_path ) {
 #if defined(SUPPORT_EXIV2)
-    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(_path);
+    Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(_path);
     assert(image.get() != 0);
     image->readMetadata();

However I think it would break building against exiv2 older than 0.28.0

Additionally I had to change this in src/CMakeLists.txt:

-- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -161,9 +161,9 @@ else()
     endif()
 endif()
 
-find_package(exiv2lib CONFIG NAMES exiv2)
+find_package(exiv2 CONFIG NAMES exiv2)
 if (exiv2lib_FOUND)
-    link_libraries(exiv2lib)
+    link_libraries(exiv2)
     target_compile_definitions(vera PUBLIC SUPPORT_EXIV2)
     target_link_libraries(vera PRIVATE exiv2lib)
     message(STATUS "EXIV2 FOUNDED")

Otherwise building glslViewer would fail in linking:

[100%] Linking CXX executable glslViewer
/usr/bin/ld: cannot find -lexiv2lib: No such file or directory
collect2: error: ld returned 1 exit status

The shared library file in my system is /usr/lib/libexiv2.so.

jnsh avatar Jan 29 '24 09:01 jnsh