zurutech / pillow-resize

Porting of Pillow resize method in C++ and OpenCV.
Apache License 2.0
123 stars 16 forks source link

make 编译错误 #17

Closed zzm422 closed 7 months ago

zzm422 commented 1 year ago

pillow-resize/libs/magic_enum/include/magic_enum.hpp:533:23: error: the type 'const auto' of constexpr variable 'magic_enum::detail::names_v<PillowResize::InterpolationMethods, false>' is not literal inline constexpr auto names_v = names<E, IsFlags>(std::make_index_sequence<count_v<E, IsFlags>>{});

/pillow-resize/libs/magic_enum/include/magic_enum.hpp:533:23: error: 'const auto magic_enum::detail::names_v<PillowResize::InterpolationMethods, false>' has incomplete type /pillow-resize/bin/Resize.cc: In function 'int main(int, char**)': /pillow-resize/bin/Resize.cc:62:68: error: no matching function for call to 'enum_names()' magic_enum::enum_names();

marcov868 commented 1 year ago

Hi, can you please give us more details on your environment (e.g. compiler, OS, OpenCV version)?

Lewis-Lu commented 8 months ago

Hi Marco,

Compiler g++ == 8.4.0, OS==Linux, OpenCV == 3.2.0

I probably met the same error here:

In file included from /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/bin/Resize.cc:21: /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp: In instantiation of ‘constexpr const auto magic_enum::detail::names_v<PillowResize::InterpolationMethods, false>’: /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:536:27: required by substitution of ‘template<class E, bool IsFlags, class D> using names_t = decltype (names_v<D, IsFlags>) [with E = PillowResize::InterpolationMethods; bool IsFlags = false; D = std::decay::type]’ /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:730:30: required by substitution of ‘template constexpr magic_enum::detail::enable_if_enum_t<E, magic_enum::detail::names_t > magic_enum::enum_names() [with E = PillowResize::InterpolationMethods]’ /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/bin/Resize.cc:62:68: required from here /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:533:23: error: the type ‘const auto’ of ‘constexpr’ variable ‘magic_enum::detail::names_v<PillowResize::InterpolationMethods, false>’ is not literal inline constexpr auto names_v = names<E, IsFlags>(std::make_index_sequence<count_v<E, IsFlags>>{}); ^~~ /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:533:23: error: ‘const auto magic_enum::detail::names_v<PillowResize::InterpolationMethods, false>’ has incomplete type /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/bin/Resize.cc: In function ‘int main(int, char**)’: /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/bin/Resize.cc:62:68: error: no matching function for call to ‘enum_names()’ magic_enum::enum_names(); ^ In file included from /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/bin/Resize.cc:21: /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:730:30: note: candidate: ‘template constexpr magic_enum::detail::enable_if_enum_t<E, magic_enum::detail::names_t > magic_enum::enum_names()’ [[nodiscard]] constexpr auto enum_names() noexcept -> detail::enable_if_enum_t<E, detail::names_t> { ^~~~~~ /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:730:30: note: substitution of deduced template arguments resulted in errors seen above /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp: In instantiation of ‘constexpr magic_enum::detail::enable_if_enum_t<E, typename std::decay<_Tp>::type> magic_enum::enum_value(std::size_t) [with E = PillowResize::InterpolationMethods; magic_enum::detail::enable_if_enum_t<E, typename std::decay<_Tp>::type> = PillowResize::InterpolationMethods; std::size_t = long unsigned int]’: /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:768:27: required from ‘constexpr magic_enum::detail::enable_if_enum_t<E, std::optional<typename std::decay<_Tp>::type> > magic_enum::enum_cast(std::string_view, BinaryPredicate) [with E = PillowResize::InterpolationMethods; BinaryPredicate = magic_enum::detail::char_equal_to; magic_enum::detail::enable_if_enum_t<E, std::optional<typename std::decay<_Tp>::type> > = std::optional; std::string_view = std::basic_string_view]’ /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:781:22: required from ‘constexpr magic_enum::detail::enable_if_enum_t<E, std::optional<typename std::decay<_Tp>::type> > magic_enum::enum_cast(std::string_view) [with E = PillowResize::InterpolationMethods; magic_enum::detail::enable_if_enum_t<E, std::optional<typename std::decay<_Tp>::type> > = std::optional; std::string_view = std::basic_string_view]’ /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/bin/Resize.cc:90:76: required from here /mnt/d/wsl_workspace/mobileVLM/test_cJSON/pillow-resize/libs/magic_enum/include/magic_enum.hpp:686:36: error: static assertion failed: magic_enum requires enum implementation and valid max and min. static_assert(detail::count_v > 0, "magic_enum requires enum implementation and valid max and min.");


bin/CMakeFiles/resize.dir/build.make:75: recipe for target 'bin/CMakeFiles/resize.dir/Resize.cc.o' failed
make[2]: *** [bin/CMakeFiles/resize.dir/Resize.cc.o] Error 1
CMakeFiles/Makefile2:959: recipe for target 'bin/CMakeFiles/resize.dir/all' failed
make[1]: *** [bin/CMakeFiles/resize.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2
marcov868 commented 7 months ago

Can you please make a test with a more recent version of gcc? If it's a problem of the compiler we can work on creating a sort of compatibility matrix to avoid this kind of problem in the future

Lewis-Lu commented 7 months ago

I set to 12.1 in aarch64 and it works, the dependency is generated by magic_enum, so might need get rid of this ?

CXX=/usr/local/cortex-a76-2022.08-gcc12.1-linux5.15/bin/aarch64-linux-gnu-g++ cmake ..

Best, Lewis

marcov868 commented 7 months ago

Unfortunately, we can't get rid of magic_enum since it streamlines a lot the use of enums in C++. But, we use it only in the executable, so if you are interested in using the library, and not the binaries, you can edit the makefile to exclude the bin and tests directories from the build.

PS: A thing we want to work on is to create a pipeline to automatically create a sort of compatibility matrix in order to avoid this kind of issue in the future.

Lewis-Lu commented 7 months ago

Thanks for the reply, I definitely would like to use the binary to test the resize effects at first, it's compiled anyway. The compatibility matrix is much welcomed !

Best, Lewis

marcov868 commented 7 months ago

I'll close the issue. Feel free to open it again if the original problem was not caused by an old version of the compiler