patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.89k stars 596 forks source link

Build error macOS Monterrey: template parameter redefines default argument #342

Closed ilciavo closed 1 year ago

ilciavo commented 2 years ago

First, thanks for sharing this cool project. When I try to build, I get the following error:

Consolidate compiler generated dependencies of target fit-model-multi
[ 37%] Building CXX object examples/CMakeFiles/fit-model-multi.dir/fit-model-multi.cpp.o
In file included from /Users/leo/Desktop/Coding/C++/eos/examples/fit-model-multi.cpp:31:
In file included from /Users/leo/Desktop/Coding/C++/eos/include/eos/render/render.hpp:27:
/Users/leo/Desktop/Coding/C++/eos/include/eos/render/SoftwareRenderer.hpp:400:42: error: template parameter redefines default argument
template <typename T, glm::precision P = glm::defaultp>
                                         ^
/Users/leo/Desktop/Coding/C++/eos/include/eos/render/SoftwareRenderer.hpp:56:42: note: previous default template argument defined here
template <typename T, glm::precision P = glm::defaultp>
                                         ^
1 error generated.
make[2]: *** [examples/CMakeFiles/fit-model-multi.dir/fit-model-multi.cpp.o] Error 1
make[1]: *** [examples/CMakeFiles/fit-model-multi.dir/all] Error 2

The error comes from include/eos/render/SoftwareRenderer.hpp, which I've managed to compile after commenting this section:

// Forward declarations (these functions should probably be moved into detail/):
template <typename T, glm::precision P = glm::defaultp>
std::vector<detail::Vertex<T, P>>
clip_polygon_to_plane_in_4d(const std::vector<detail::Vertex<T, P>>& vertices,
                            const glm::tvec4<T, P>& plane_normal);

I'm using clang 13.1.6 and homebrew versions of the following libraries cereal, eigen, glm, and toml11

Cheers

patrikhuber commented 2 years ago

Hi,

Thanks a lot for the report! I'll try and fix this in one of the next versions.

Best wishes, Patrik

patrikhuber commented 2 years ago

I had a feeling that I've seen this before, couldn't find it in any past issue but I am quite sure. For some reason, clang doesn't like glm::precision P = glm::defaultp. So actually you don't need to comment the whole forward declaration to fix this, you just need to remove the default argument = glm::defaultp. Does that fix it?

ilciavo commented 2 years ago

Changing line 56 to template <typename T, glm::precision P> does the magic I understand that line 400 template <typename T, glm::precision P = glm::defaultp> passes the default argument, and it should remain unmodified. right? Cheers

patrikhuber commented 2 years ago

Thank you for checking!

I don't know why line 400 would work - perhaps that template is not instantiated, whereas the other one is?

I'm leaving this issue open, I should update the CI at some point, test on all compilers again and make sure it all compiles. Thank you again for reporting it :-).

ilciavo commented 2 years ago

Super! I will explore a toy example following this. Thanks for sharing

patrikhuber commented 1 year ago

I've just released eos v1.4.0, which removed all of glm, and now uses Eigen everywhere. So these default template argument errors with glm should be gone now as well. If there are other/new issues with macOS, please let me know via new issues! :-)