尝试从 makefile 构建 assimp 时出现多个 -fpermissive 错误

getting multiple -fpermissive errors when trying to build assimp from makefile

提问人:Kevin Shaughnessy 提问时间:7/21/2023 更新时间:8/29/2023 访问量:51

问:

我已经使用 git 下载了 assimp 源代码。然后我使用了 cmake,但我必须添加标志 - 为了回避一些早期的编译问题,在这些问题上,我收到有关 stb_i.h 中函数被定义但未使用的错误。当我键入时,我收到以下编译错误git clone https://github.com/assimp/assimp.gitDASSIMP_WARNINGS_AS_ERRORS=OFFsudo make

/home/kshaugnnessy/Downloads/engine/assimp/code/PostProcessing/JoinVerticesProcess.cpp:226:13: error: specialization of ‘template<class _Tp> struct std::hash’ in different namespace [-fpermissive]
 struct std::hash<Vertex> {
             ^
In file included from /usr/include/c++/5/bits/basic_string.h:5471:0,
                 from /usr/include/c++/5/string:52,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iterator:64,
                 from /home/kshaugnnessy/Downloads/engine/assimp/contrib/utf8cpp/source/utf8/core.h:31,
                 from /home/kshaugnnessy/Downloads/engine/assimp/contrib/utf8cpp/source/utf8/checked.h:31,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/../contrib/utf8cpp/source/utf8.h:31,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/assimp/types.h:79,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/assimp/Importer.hpp:60,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/assimp/GenericProperty.h:52,
                 from /home/kshaugnnessy/Downloads/engine/assimp/code/Common/BaseProcess.h:46,
                 from /home/kshaugnnessy/Downloads/engine/assimp/code/PostProcessing/JoinVerticesProcess.h:48,
                 from /home/kshaugnnessy/Downloads/engine/assimp/code/PostProcessing/JoinVerticesProcess.cpp:48:
/usr/include/c++/5/bits/functional_hash.h:58:12: error:   from definition of ‘template<class _Tp> struct std::hash’ [-fpermissive]
     struct hash;
            ^
/home/kshaugnnessy/Downloads/engine/assimp/code/PostProcessing/JoinVerticesProcess.cpp:235:13: error: specialization of ‘template<class _Tp> struct std::equal_to’ in different namespace [-fpermissive]
 struct std::equal_to<Vertex> {
             ^
In file included from /usr/include/c++/5/string:48:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iterator:64,
                 from /home/kshaugnnessy/Downloads/engine/assimp/contrib/utf8cpp/source/utf8/core.h:31,
                 from /home/kshaugnnessy/Downloads/engine/assimp/contrib/utf8cpp/source/utf8/checked.h:31,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/../contrib/utf8cpp/source/utf8.h:31,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/assimp/types.h:79,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/assimp/Importer.hpp:60,
                 from /home/kshaugnnessy/Downloads/engine/assimp/include/assimp/GenericProperty.h:52,
                 from /home/kshaugnnessy/Downloads/engine/assimp/code/Common/BaseProcess.h:46,
                 from /home/kshaugnnessy/Downloads/engine/assimp/code/PostProcessing/JoinVerticesProcess.h:48,
                 from /home/kshaugnnessy/Downloads/engine/assimp/code/PostProcessing/JoinVerticesProcess.cpp:48:
/usr/include/c++/5/bits/stl_function.h:332:12: error:   from definition of ‘template<class _Tp> struct std::equal_to’ [-fpermissive]
     struct equal_to;
            ^
code/CMakeFiles/assimp.dir/build.make:747: recipe for target 'code/CMakeFiles/assimp.dir/PostProcessing/JoinVerticesProcess.cpp.o' failed
make[2]: *** [code/CMakeFiles/assimp.dir/PostProcessing/JoinVerticesProcess.cpp.o] Error 1
CMakeFiles/Makefile2:203: recipe for target 'code/CMakeFiles/assimp.dir/all' failed
make[1]: *** [code/CMakeFiles/assimp.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

我能做些什么来使它工作?

谢谢。

C++ CMake MakeFile 编译 Assimp

评论

0赞 Drew Dormann 7/21/2023
您可能需要拉取一个官方版本才能获得可靠的行为,而不是尝试构建此时 master 分支中的任何内容。
1赞 Ted Lyngmo 7/21/2023
我刚刚编译了最新的master,它编译得很干净。该错误似乎已对源代码进行了一些更改。你有什么改变吗?
1赞 Tsyvarev 7/21/2023
您使用哪个 gcc 版本?似乎是该答案中描述的错误,已在 gcc 7 中修复。

答:

0赞 KimKulling 8/29/2023 #1

与这篇文章相关的可能是 g++ 错误,这似乎是一个编译器错误。周围的块不在 std-namespace 中,这似乎会导致编译器警告。