2013-03-08 105 views
2

當我嘗試用gli/gli.hpp編譯時,出現錯誤。我從來沒有碰過這些文件。所以我不知道如何解決這個問題。編譯時出現OpenGL GLI錯誤

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’ 

回答

0

我認爲問題在於你沒有告訴你的編譯器你需要使用C++ 11標準進行編譯。

如果你正在使用gcc,那麼你必須在命令行上傳遞

-std=c++11 

(或-std = C++ 0x中,如果你使用gcc的舊版本)

0

簡而言之,您的C++編譯器比用於開發gli的編譯器更爲嚴格。仔細檢查錯誤,可以在g++行上添加-fpermissive,使第一個可以被禁止(不一定是正確的)。這個錯誤看起來像來自使用了錯誤的返回類型上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’ 

對於這一塊,我認爲問題是,在load_dds.hppgli::loadStorageDDS被delcared作爲函數,但未標記爲inline,在那裏,這就是在load_dds.inl回事。 .inl機制似乎是Microsoft調製的,因此您可能需要修改.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’