我是Ogre3D的初学者,我用ogre3D构建了mi first程序,但是当我试图编译该程序时,我得到了以下错误:
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&)' 然后继续修复
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
谢谢你的回答。
发布于 2012-09-09 15:12:13
这是链接器错误。使用pkg-config --libs检索正确的链接器选项
g++ -o test test.cpp -Wall $(pkg-config --cflags OGRE) $(pkg-config --libs OGRE) -lboost_system如果已在非标准位置(例如/opt/ogre)安装了OGRE,则可能需要使用PKG_CONFIG_PATH环境变量集调用pkg-config:
PKG_CONFIG_PATH=/opt/ogre/lib/pkgconfig pkg-config --libs OGRE发布于 2012-09-10 13:22:18
这是链接器错误,但不是对Ogre3d,而是对STL (标准模板库)。原因是您使用的是gcc,而您应该使用g++。但是,我感到惊讶的是,您并没有得到Ogre的链接器错误,解决方案就像Thomas建议的那样(尽管他在示例中也使用了"g++“)。
https://stackoverflow.com/questions/12340198
复制相似问题