首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >linux上的错误Ogre3D

linux上的错误Ogre3D
EN

Stack Overflow用户
提问于 2012-09-09 15:05:21
回答 2查看 264关注 0票数 2

我是Ogre3D的初学者,我用ogre3D构建了mi first程序,但是当我试图编译该程序时,我得到了以下错误:

代码语言:javascript
复制
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. 我手动编译程序:

代码语言:javascript
复制
gcc test.cpp  -o test.o test

我的档案测试是:

代码语言:javascript
复制
#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

谢谢你的回答。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-09-09 15:12:13

这是链接器错误。使用pkg-config --libs检索正确的链接器选项

代码语言:javascript
复制
g++ -o test test.cpp -Wall $(pkg-config --cflags OGRE) $(pkg-config --libs OGRE) -lboost_system

如果已在非标准位置(例如/opt/ogre)安装了OGRE,则可能需要使用PKG_CONFIG_PATH环境变量集调用pkg-config:

代码语言:javascript
复制
PKG_CONFIG_PATH=/opt/ogre/lib/pkgconfig pkg-config --libs OGRE
票数 1
EN

Stack Overflow用户

发布于 2012-09-10 13:22:18

这是链接器错误,但不是对Ogre3d,而是对STL (标准模板库)。原因是您使用的是gcc,而您应该使用g++。但是,我感到惊讶的是,您并没有得到Ogre的链接器错误,解决方案就像Thomas建议的那样(尽管他在示例中也使用了"g++“)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12340198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档