2012-09-09 41 views
1

我在OGRE3D初學者和我建立OGRE3D MI第一個程序,但是當我試圖編譯程序我得到這個錯誤:錯誤OGRE3D在Linux上

In function `main': 
test.cpp:(.text+0x14): undefined reference to `std::allocator<char>::allocator()' 
test.cpp:(.text+0x30): undefined reference to `std::basic_string<char,                 
std::char_traits<char>, std::allocator<char> >::basic_string(char const*, 
std::allocator<char> const&)' 

test.cpp:(.text+0x40): undefined reference to `std::allocator<char>::allocator()' 
test.cpp:(.text+0x5c): undefined reference to `std::basic_string<char,  
std::char_traits<char>, std::allocator<char> >::basic_string(char const*, 
std::allocator<char> const&)' 

test.cpp:(.text+0x6c): undefined reference to `std::allocator<char>::allocator()' 
test.cpp:(.text+0x88): undefined reference to `std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::basic_string(char const*, 
std::allocator<char> const&)' 

,並繼續修復

  1. 我手動編譯程序:
gcc test.cpp -o test.o test 

我的文件測試是這樣的:

#include <Ogre.h> 

using namespace Ogre; 

int main() 
{ 
Root* root= new Root(); 

if(!root->restoreConfig()) 
{ 
    root->showConfigDialog(); 
    root->saveConfig(); 
} 
return 0; 
} 

如何解決我的問題?

我在使用Debian Wheezy。

版本Ogre3D:1.8

感謝您的回答。

回答

1

這是一個鏈接器錯誤。 使用pkg-config --libs檢索正確的連接選項

g++ -o test test.cpp -Wall $(pkg-config --cflags OGRE) $(pkg-config --libs OGRE) -lboost_system 

如果你已經在非標準位置安裝OGRE(比如/opt/ogre),您可能需要調用pkg配置與PKG_CONFIG_PATH環境變量設置:

PKG_CONFIG_PATH=/opt/ogre/lib/pkgconfig pkg-config --libs OGRE 
+0

謝謝,它的工作。 –

0

這是一個鏈接器錯誤,但不是Ogre3d,而是STL(標準模板庫)。原因是你使用gcc,當你應該使用g ++。然而,我很驚訝你也沒有將鏈接器錯誤傳遞給Ogre,並且解決方案就像Thomas所建議的(雖然他在他的例子中也使用了「g ++」)。

+0

您也可以在freenode irc網絡上的#ogre3d中詢問這些類型的問題。 –