DGtal-team / DGtal

Digital Geometry Tools and Algorithm Library
https://dgtal.org
GNU Lesser General Public License v3.0
370 stars 115 forks source link

Compilation error - clang - Ubuntu 20.04 #1509

Closed skn123 closed 3 years ago

skn123 commented 4 years ago

/home/sumit/srcs/DGtal/src/DGtal/io/colormaps/GradientColorMap.ih:227:32: error: no viable conversion from '__wrap_iter<std::__1::vector<DGtal::Color, std::__1::allocator<DGtal::Color>>::const_pointer>' to '__wrap_iter<std::__1::vector<DGtal::Color, std::__1::allocator<DGtal::Color>>::pointer>' std::vector<Color>::iterator it = myColors.begin(); ^ ~~~~~~~~~~~~~~~~ /usr/lib/llvm-11/bin/../include/c++/v1/iterator:1404:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::__1::vector<DGtal::Color, std::__1::allocator<DGtal::Color>>::const_iterator' (aka '__wrap_iter<const DGtal::Color *>') to 'const std::__1::__wrap_iter<DGtal::Color *> &' for 1st argument class __wrap_iter ^ /usr/lib/llvm-11/bin/../include/c++/v1/iterator:1404:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'std::__1::vector<DGtal::Color, std::__1::allocator<DGtal::Color>>::const_iterator' (aka '__wrap_iter<const DGtal::Color *>') to 'std::__1::__wrap_iter<DGtal::Color *> &&' for 1st argument /usr/lib/llvm-11/bin/../include/c++/v1/iterator:1529:60: note: candidate constructor not viable: no known conversion from 'std::__1::vector<DGtal::Color, std::__1::allocator<DGtal::Color>>::const_iterator' (aka '__wrap_iter<const DGtal::Color *>') to 'std::__1::__wrap_iter<DGtal::Color *>::iterator_type' (aka 'DGtal::Color *') for 1st argument _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} ^ /usr/lib/llvm-11/bin/../include/c++/v1/iterator:1426:9: note: candidate template ignored: requirement 'is_convertible<const DGtal::Color *, DGtal::Color *>::value' was not satisfied [with _Up = const DGtal::Color *] __wrap_iter(const __wrap_iter<_Up>& __u, OS: UBuntu 20.04 Compiler Clang-11 STDLIB=libc++

/usr/bin/ld: examples/geometry/curves/CMakeFiles/freemanChainDisplay.dir/freemanChainDisplay.cpp.o: in functionDGtal::MagickReader<DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2u, int> >, unsigned char>, DGtal::functors::MagickCast >::importImage(std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const&, DGtal::functors::MagickCast const&, bool)': freemanChainDisplay.cpp:(.text._ZN5DGtal12MagickReaderINS_25ImageContainerBySTLVectorINS_15HyperRectDomainINS_7SpaceNDILj2EiEEEEhEENS_8functors10MagickCastIhEEE11importImageERKNSt3112basic_stringIcNSB_11char_traitsIcEENSB_9allocatorIcEEEERKS9_b[_ZN5DGtal12MagickReaderINS_25ImageContainerBySTLVectorINS_15HyperRectDomainINS_7SpaceNDILj2EiEEEEhEENS_8functors10MagickCastIhEEE11importImageERKNSt3112basic_stringIcNSB_11char_traitsIcEENSB_9allocatorIcEEEERKS9_b]+0x42): undefined reference to Magick::Image::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)' clang: error: linker command failed with exit code 1 (use -v to see invocation)

rolanddenis commented 4 years ago

Hi,

thanks for the report!

I suppose you are using DGtal v1.0? This error should be fixed since https://github.com/DGtal-team/DGtal/commit/a005ca37bae2a3d1c512484f86de5cae0e579075 (merged in https://github.com/DGtal-team/DGtal/pull/1486) ... could you try with the master and let me know if it also works for you?

skn123 commented 4 years ago

I have done a fresh checkout from master

rolanddenis commented 4 years ago

Can you please double check? I ask you that because the beginning of the error message

/home/sumit/srcs/DGtal/src/DGtal/io/colormaps/GradientColorMap.ih:227:32: error: no viable conversion from
'__wrap_iter<std::__1::vector<DGtal::Color, std::__1::allocator<DGtal::Color>>::const_pointer>' to
'__wrap_iter<std::__1::vector<DGtal::Color, std::__1::allocator<DGtal::Color>>::pointer>'
std::vector<Color>::iterator it = myColors.begin();

doesn't match the current state of this file:

std::vector<Color>::const_iterator it = myColors.begin();

About your specifications, did you mean Clang-10 or do you used the still-in-development version 11 of Clang?

I will take a look at your another error later!

skn123 commented 4 years ago

@rolanddenis I am building everything with -std=c++17 -stdlib=libc++. I fixed that error with const_iterator. Now, due to c++17, I am getting a different error: `In file included from /home/sumit/srcs/DGtal/examples/doc-examples/exampleCatch.cpp:48: In file included from /home/sumit/srcs/DGtal/examples/doc-examples/DGtalCatch.h:10: /home/sumit/srcs/DGtal/examples/doc-examples/catch.hpp:6078:26: error: no member named 'random_shuffle' in namespace 'std' std::random_shuffle( sorted.begin(), sorted.end(), rng );


`
Looks like random_shuffle has been removed in c++17. FYI, there is another problem coming when I include ITK 5.2 (latest from master), but built with c++17. It fails the ITK CPP-11 check in your cmake file. I had to comment that out and now it builds fine.

And
`In file included from /home/sumit/srcs/DGtal/examples/geometry/volumes/distance/toricdomainvolumetric.cpp:43:
In file included from /usr/lib/llvm-11/bin/../include/c++/v1/iostream:37:
In file included from /usr/lib/llvm-11/bin/../include/c++/v1/ios:215:
In file included from /usr/lib/llvm-11/bin/../include/c++/v1/__locale:14:
In file included from /usr/lib/llvm-11/bin/../include/c++/v1/string:506:
In file included from /usr/lib/llvm-11/bin/../include/c++/v1/string_view:175:
In file included from /usr/lib/llvm-11/bin/../include/c++/v1/__string:57:
/usr/lib/llvm-11/bin/../include/c++/v1/algorithm:2595:5: error: static_assert failed due to requirement '__is_cpp17_forward_iterator<DGtal::ConstIteratorAdapter<DGtal::HyperRectDomain_Iterator<DGtal::PointVector<2, int, std::__1::array<int, 2>>>, DGtal::DistanceTransformation<DGtal::SpaceND<2, int>, DGtal::functors::SimpleThresholdForegroundPredicate<DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, unsigned int>>, DGtal::ExactPredicateLpSeparableMetric<DGtal::SpaceND<2, int>, 2, long>, DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, DGtal::PointVector<2, int, std::__1::array<int, 2>>>>, double>>::value' "std::max_element requires a ForwardIterator"
    static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-11/bin/../include/c++/v1/algorithm:2614:19: note: in instantiation of function template specialization 'std::__1::max_element<DGtal::ConstIteratorAdapter<DGtal::HyperRectDomain_Iterator<DGtal::PointVector<2, int, std::__1::array<int, 2>>>, DGtal::DistanceTransformation<DGtal::SpaceND<2, int>, DGtal::functors::SimpleThresholdForegroundPredicate<DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, unsigned int>>, DGtal::ExactPredicateLpSeparableMetric<DGtal::SpaceND<2, int>, 2, long>, DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, DGtal::PointVector<2, int, std::__1::array<int, 2>>>>, double>, std::__1::__less<double, double>>' requested here
    return _VSTD::max_element(__first, __last,
                  ^
/home/sumit/srcs/DGtal/examples/geometry/volumes/distance/toricdomainvolumetric.cpp:119:49: note: in instantiation of function template specialization 'std::__1::max_element<DGtal::ConstIteratorAdapter<DGtal::HyperRectDomain_Iterator<DGtal::PointVector<2, int, std::__1::array<int, 2>>>, DGtal::DistanceTransformation<DGtal::SpaceND<2, int>, DGtal::functors::SimpleThresholdForegroundPredicate<DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, unsigned int>>, DGtal::ExactPredicateLpSeparableMetric<DGtal::SpaceND<2, int>, 2, long>, DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, DGtal::PointVector<2, int, std::__1::array<int, 2>>>>, double>>' requested here
  const DTL2::Value       maxv2       = * (std::max_element(dtL2.constRange().begin(), dtL2.constRange().end()));
                                                ^
1 error generated.
`
skn123 commented 4 years ago

I have a feeling that DGtal (tests) are not configured for c++17 (stdlib=libc++) ?

rolanddenis commented 4 years ago

@rolanddenis I am building everything with -std=c++17 -stdlib=libc++. I fixed that error with const_iterator.

:+1:

Now, due to c++17, I am getting a different error: In file included from /home/sumit/srcs/DGtal/examples/doc-examples/exampleCatch.cpp:48: In file included from /home/sumit/srcs/DGtal/examples/doc-examples/DGtalCatch.h:10: /home/sumit/srcs/DGtal/examples/doc-examples/catch.hpp:6078:26: error: no member named 'random_shuffle' in namespace 'std' std::random_shuffle( sorted.begin(), sorted.end(), rng ); ~^ ` Looks like random_shuffle has been removed in c++17.

Yes, you're right: https://en.cppreference.com/w/cpp/algorithm/random_shuffle It should be replaced with std::shuffle using an appropriate random generator. I will submit a separate issue to update Catch to the last version (before v2) that should fix this issue.

FYI, there is another problem coming when I include ITK 5.2 (latest from master), but built with c++17. It fails the ITK CPP-11 check in your cmake file. I had to comment that out and now it builds fine.

It works for me with ITK 4.12. I will try with 5.2 later but I think this check can be safely removed now (added in 2012...)

And In file included from /home/sumit/srcs/DGtal/examples/geometry/volumes/distance/toricdomainvolumetric.cpp:43: In file included from /usr/lib/llvm-11/bin/../include/c++/v1/iostream:37: In file included from /usr/lib/llvm-11/bin/../include/c++/v1/ios:215: In file included from /usr/lib/llvm-11/bin/../include/c++/v1/__locale:14: In file included from /usr/lib/llvm-11/bin/../include/c++/v1/string:506: In file included from /usr/lib/llvm-11/bin/../include/c++/v1/string_view:175: In file included from /usr/lib/llvm-11/bin/../include/c++/v1/__string:57: /usr/lib/llvm-11/bin/../include/c++/v1/algorithm:2595:5: error: static_assert failed due to requirement '__is_cpp17_forward_iterator<DGtal::ConstIteratorAdapter<DGtal::HyperRectDomain_Iterator<DGtal::PointVector<2, int, std::__1::array<int, 2>>>, DGtal::DistanceTransformation<DGtal::SpaceND<2, int>, DGtal::functors::SimpleThresholdForegroundPredicate<DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, unsigned int>>, DGtal::ExactPredicateLpSeparableMetric<DGtal::SpaceND<2, int>, 2, long>, DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, DGtal::PointVector<2, int, std::__1::array<int, 2>>>>, double>>::value' "std::max_element requires a ForwardIterator" static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/lib/llvm-11/bin/../include/c++/v1/algorithm:2614:19: note: in instantiation of function template specialization 'std::__1::max_element<DGtal::ConstIteratorAdapter<DGtal::HyperRectDomain_Iterator<DGtal::PointVector<2, int, std::__1::array<int, 2>>>, DGtal::DistanceTransformation<DGtal::SpaceND<2, int>, DGtal::functors::SimpleThresholdForegroundPredicate<DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, unsigned int>>, DGtal::ExactPredicateLpSeparableMetric<DGtal::SpaceND<2, int>, 2, long>, DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, DGtal::PointVector<2, int, std::__1::array<int, 2>>>>, double>, std::__1::__less<double, double>>' requested here return _VSTD::max_element(__first, __last, ^ /home/sumit/srcs/DGtal/examples/geometry/volumes/distance/toricdomainvolumetric.cpp:119:49: note: in instantiation of function template specialization 'std::__1::max_element<DGtal::ConstIteratorAdapter<DGtal::HyperRectDomain_Iterator<DGtal::PointVector<2, int, std::__1::array<int, 2>>>, DGtal::DistanceTransformation<DGtal::SpaceND<2, int>, DGtal::functors::SimpleThresholdForegroundPredicate<DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, unsigned int>>, DGtal::ExactPredicateLpSeparableMetric<DGtal::SpaceND<2, int>, 2, long>, DGtal::ImageContainerBySTLVector<DGtal::HyperRectDomain<DGtal::SpaceND<2, int>>, DGtal::PointVector<2, int, std::__1::array<int, 2>>>>, double>>' requested here const DTL2::Value maxv2 = * (std::max_element(dtL2.constRange().begin(), dtL2.constRange().end())); ^ 1 error generated.

Yes, this issue has already been submited in https://github.com/DGtal-team/DGtal/issues/1437 and fixed in https://github.com/DGtal-team/DGtal/pull/1475 . The faulty line listed in your error message (last line) doesn't match the current master state that is:

const DTL2::Value       maxv2       = * (boost::first_max_element(dtL2.constRange().begin(), dtL2.constRange().end()));

Did you check that you really are on master branch and up to date?

I have a feeling that DGtal (tests) are not configured for c++17 (stdlib=libc++) ?

Yes, you're right, I think it works great in C++14 but it has not been yet tested in newer version of the standard...

rolanddenis commented 4 years ago

The error with Catch is also fixed in master since https://github.com/DGtal-team/DGtal/pull/1419, so you shouldn't get this error with the master of DGtal.

rolanddenis commented 4 years ago

I have a feeling that DGtal (tests) are not configured for c++17 (stdlib=libc++) ?

Yes, you're right, I think it works great in C++14 but it has not been yet tested in newer version of the standard...

BTW, beside some issues (with ITK, with detection of components of CGAL -- see #1136# --, and a small fix in Viewer3D.ih), all tests and examples compile fine with -std=c++17 (Ubuntu 18.04, LLVM 10.0.0).