Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error - clang - Ubuntu 20.04 #1509

Closed
skn123 opened this issue Sep 13, 2020 · 8 comments
Closed

Compilation error - clang - Ubuntu 20.04 #1509

skn123 opened this issue Sep 13, 2020 · 8 comments

Comments

@skn123
Copy link

skn123 commented Sep 13, 2020

/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 function DGtal::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_8functors10MagickCastIhEEE11importImageERKNSt3__112basic_stringIcNSB_11char_traitsIcEENSB_9allocatorIcEEEERKS9_b[_ZN5DGtal12MagickReaderINS_25ImageContainerBySTLVectorINS_15HyperRectDomainINS_7SpaceNDILj2EiEEEEhEENS_8functors10MagickCastIhEEE11importImageERKNSt3__112basic_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
Copy link
Member

Hi,

thanks for the report!

I suppose you are using DGtal v1.0? This error should be fixed since a005ca3 (merged in #1486) ... could you try with the master and let me know if it also works for you?

@skn123
Copy link
Author

skn123 commented Sep 13, 2020

I have done a fresh checkout from master

@rolanddenis
Copy link
Member

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
Copy link
Author

skn123 commented Sep 13, 2020

@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
Copy link
Author

skn123 commented Sep 13, 2020

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

@rolanddenis
Copy link
Member

rolanddenis commented Sep 13, 2020

@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.

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 #1437 and fixed in #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
Copy link
Member

The error with Catch is also fixed in master since #1419, so you shouldn't get this error with the master of DGtal.

@rolanddenis
Copy link
Member

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).

@dcoeurjo dcoeurjo closed this as completed Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants