trufanov-nok / scantailor-universal

ScanTailor Universal - a fork based on Enhanced+Featured+Master versions of ST
http://scantailor.org
Other
181 stars 16 forks source link

build error: AutoPtr’ in ‘class Exiv2::Image’ does not name a type #131

Closed muralikodali closed 1 year ago

muralikodali commented 1 year ago

building from source giving the following error:

[ 90%] Building CXX object src/core/filters/output/CMakeFiles/output.dir/DewarpingMode.cpp.o
[ 90%] Building CXX object src/core/filters/output/CMakeFiles/output.dir/ChangeDewarpingWidget.cpp.o
[ 91%] Building CXX object src/core/filters/output/CMakeFiles/output.dir/DepthPerception.cpp.o
[ 91%] Building CXX object src/core/filters/output/CMakeFiles/output.dir/OrderByModeProvider.cpp.o
[ 91%] Building CXX object src/core/filters/output/CMakeFiles/output.dir/OrderBySourceColor.cpp.o
[ 91%] Building CXX object src/core/filters/output/CMakeFiles/output.dir/OrderByDewarpingModeProvider.cpp.o
[ 92%] Building CXX object src/core/filters/output/CMakeFiles/output.dir/ImageMetadataCopier.cpp.o
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp: In static member function ‘static bool ImageMetadataCopier::iccProfileDefined(const QString&)’:
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp:12:25: error: ‘AutoPtr’ in ‘class Exiv2::Image’ does not name a type
   12 |     const Exiv2::Image::AutoPtr src_image = Exiv2::ImageFactory::open(filename.toStdString());
      |                         ^~~~~~~
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp:14:9: error: ‘src_image’ was not declared in this scope
   14 |     if (src_image.get()) {
      |         ^~~~~~~~~
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp: In static member function ‘static bool ImageMetadataCopier::copyMetadata(const QString&, const QString&)’:
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp:30:37: error: ‘AutoPtr’ in ‘class Exiv2::Image’ does not name a type
   30 |                 const Exiv2::Image::AutoPtr src_image = Exiv2::ImageFactory::open(src_img.toStdString());
      |                                     ^~~~~~~
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp:33:13: error: ‘src_image’ was not declared in this scope; did you mean ‘src_img’?
   33 |         if (src_image.get()) {
      |             ^~~~~~~~~
      |             src_img
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp:41:53: error: ‘AutoPtr’ in ‘class Exiv2::Image’ does not name a type
   41 |                                 const Exiv2::Image::AutoPtr dst_image = Exiv2::ImageFactory::open(dst_img.toStdString());
      |                                                     ^~~~~~~
/home/murali/Downloads/scantailor/src/core/filters/output/ImageMetadataCopier.cpp:43:17: error: ‘dst_image’ was not declared in this scope; did you mean ‘dst_img’?
   43 |                 dst_image->readMetadata();
      |                 ^~~~~~~~~
      |                 dst_img
make[2]: *** [src/core/filters/output/CMakeFiles/output.dir/build.make:694: src/core/filters/output/CMakeFiles/output.dir/ImageMetadataCopier.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1503: src/core/filters/output/CMakeFiles/output.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
trufanov-nok commented 1 year ago

If you're building on linux try to install libexiv2-dev: sudo apt install libexiv2-dev

muralikodali commented 1 year ago

I am on archlinux. please suggest the proper package to install ?

trufanov-nok commented 1 year ago

try just exiv2

muralikodali commented 1 year ago

exiv2 is already installed

trufanov-nok commented 1 year ago

could you post the output of cmake .. command that you use to build the sources?

muralikodali commented 1 year ago

please check the attached file for the cmake output.

cmake-output.txt

trufanov-nok commented 1 year ago

Ok, I've tried to build the project in archlinux in VirtualBox and reproduced your problem. It seems arch uses newer exiv2 library than ubuntu. And in new library author's replaced AutoPtr with UniquePtr: https://github.com/Exiv2/exiv2/commit/0bbaa6eff3c93dfc5242af4069ccff56f48ba5fb

So all you need to do is to edit the src/core/filters/output/ImageMetadataCopier.cpp:

  1. replace all Exiv2::AutoPtr with Exiv2::UniquePtr (there are 6 of them, i guess)
  2. replace the line dst_image->setIccProfile(*src_image->iccProfile()); with 2 lines:
    Exiv2::DataBuf profile = src_image->iccProfile();
    dst_image->setIccProfile(std::move(profile));

Providing that the code compiles successfully.

I'll patch the sources when I'll have more spare time and think out how to distinguish new exiv2 lib from the old one.

muralikodali commented 1 year ago

thanks for your suggestion. After editing src/core/filters/output/ImageMetadataCopier.cpp as suggested by you, program complied successfully.

👍