2

当我尝试使用 gli/gli.hpp 进行编译时,出现以下错误。我以前从未接触过这些文件。所以我不知道如何解决这个问题。

In file included from /usr/include/gli/gli.hpp:42:0,
              from window.cpp:4:
/usr/include/gli/./core/storage.hpp:89:25: error: declaration of ‘gli::storage::format_type gli::storage::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

In file included from /usr/include/gli/gli.hpp:45:0,
              from window.cpp:4:
/usr/include/gli/./core/texture2d.hpp:71:24: error: declaration of ‘gli::texture2D::format_type gli::texture2D::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

In file included from /usr/include/gli/gli.hpp:46:0
             from window.cpp:4:
/usr/include/gli/./core/texture2d_array.hpp:72:24: error: declaration of ‘gli::texture2DArray::format_type gli::texture2DArray::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

In file included from /usr/include/gli/gli.hpp:47:0,
             from window.cpp:4:
/usr/include/gli/./core/texture3d.hpp:71:24: error: declaration of ‘gli::texture3D::format_type gli::texture3D::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

In file included from /usr/include/gli/gli.hpp:51:0,
             from window.cpp:4:
/usr/include/gli/./core/load_dds.hpp:37:3: error: ‘string’ is not a member of ‘std’

In file included from /usr/include/gli/./core/load_dds.hpp:41:0,
             from /usr/include/gli/gli.hpp:51,
             from window.cpp:4:
/usr/include/gli/./core/load_dds.inl: In function ‘gli::storage gli::loadStorageDDS(const string&)’:
/usr/include/gli/./core/load_dds.inl:303:1: error: ‘gli::storage gli::loadStorageDDS(const string&)’ redeclared as different kind of symbol
/usr/include/gli/./core/load_dds.hpp:36:10: error: previous declaration of ‘gli::storage gli::loadStorageDDS’
4

2 回答 2

0

我认为问题在于您没有告诉编译器您需要使用 C++11 标准进行编译。

如果您使用的是 gcc,那么您必须通过

-std=c++11

在你的命令行上(或者 -std=c++0x 如果你使用的是旧版本的 gcc)

于 2013-04-04T03:56:38.613 回答
0

简短的回答似乎是您的 C++ 编译器比用于开发 gli 的编译器更严格。-fpermissive通过错误,第一个可以通过在您的g++线路上添加来静音(不一定正确修复) 。这个错误看起来像是来自使用错误的返回类型gli::storage::format()

In file included from /usr/include/gli/gli.hpp:42:0,
              from window.cpp:4:
/usr/include/gli/./core/storage.hpp:89:25: error: declaration of ‘gli::storage::format_type gli::storage::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

In file included from /usr/include/gli/gli.hpp:45:0,
              from window.cpp:4:
/usr/include/gli/./core/texture2d.hpp:71:24: error: declaration of ‘gli::texture2D::format_type gli::texture2D::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

In file included from /usr/include/gli/gli.hpp:46:0
             from window.cpp:4:
/usr/include/gli/./core/texture2d_array.hpp:72:24: error: declaration of ‘gli::texture2DArray::format_type gli::texture2DArray::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

In file included from /usr/include/gli/gli.hpp:47:0,
             from window.cpp:4:
/usr/include/gli/./core/texture3d.hpp:71:24: error: declaration of ‘gli::texture3D::format_type gli::texture3D::format() const’ [-fpermissive]
/usr/include/gli/./core/format.hpp:36:8: error: changes meaning of ‘format’ from ‘enum gli::format’ [-fpermissive]

以下错误似乎是包含错误头文件的情况。特别是,load_dds.hpp包括另一个头文件 ( storage.hpp),其中包括<cstring>,而不是<string>,这是 C++ 声明std::string的 . 快速修复是添加<string>storage.hpp您下载的副本中,并提交错误。

In file included from /usr/include/gli/gli.hpp:51:0,
             from window.cpp:4:
/usr/include/gli/./core/load_dds.hpp:37:3: error: ‘string’ is not a member of ‘std’

对于这个,我认为问题在于 in被定义为一个函数load_dds.hppgli::loadStorageDDS但没有标记为 being inline,这就是 in 正在发生的事情load_dds.inl。该.inl机制似乎是微软的混合物,因此您可能需要修改.hpp以包含.inl实现以保持一致。(这是一个猜测,顺便说一句)。

In file included from /usr/include/gli/./core/load_dds.hpp:41:0,
             from /usr/include/gli/gli.hpp:51,
             from window.cpp:4:
/usr/include/gli/./core/load_dds.inl: In function ‘gli::storage gli::loadStorageDDS(const string&)’:
/usr/include/gli/./core/load_dds.inl:303:1: error: ‘gli::storage gli::loadStorageDDS(const string&)’ redeclared as different kind of symbol
/usr/include/gli/./core/load_dds.hpp:36:10: error: previous declaration of ‘gli::storage gli::loadStorageDDS’
于 2013-03-08T16:24:47.367 回答