1

我需要在 Qt 4 中集成 Ogre 3d。我发现了一些不幸过时的代码和建议。我喜欢这个教程

http://irmatden.developpez.com/tutoriels/qt/integration-ogre-qt/

它适用于 Ogre 1.4.9 (Eihorn),但不适用于最新版本 1.7.0。使用最近的应用程序编译应用程序会导致链接器错误

ogrewidget.o:在函数“OgreWidget::~OgreWidget()”中:
ogrewidget.cpp:(.text+0x5b6): 未定义引用 `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o:在函数“OgreWidget::~OgreWidget()”中:
ogrewidget.cpp:(.text+0x666): 未定义引用`Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o:在函数“OgreWidget::~OgreWidget()”中:
ogrewidget.cpp:(.text+0x6f6): 未定义引用`Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o:在函数“OgreWidget::initOgreSystem()”中:
ogrewidget.cpp:(.text+0x1cfb): 未定义引用`Ogre::NedPoolingImpl::allocBytes(unsigned int, char const*, int, char const*)'
ogrewidget.cpp:(.text+0x1dde): 未定义引用 `Ogre::Root::initialise(bool, std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)'
ogrewidget.cpp:(.text+0x2278): 未定义引用`Ogre::Root::createRenderWindow(std::basic_string, std::allocator > const&, unsigned int, unsigned int, bool, std::map, std: :allocator >, std::basic_string, std::allocator >, std::less, std::allocator > >, Ogre::STLAllocator, std::allocator > const, std::basic_string, std::allocator > > , Ogre::CategorisedAllocPolicy > > const*)'
ogrewidget.cpp:(.text+0x2c31): 未定义引用`Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: 在函数`std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::basic_string, std::allocator > >, std::_Select1st, std::分配器 > const, std::basic_string, std::allocator > > >, std::less, std::allocator > >, Ogre::STLAllocator, std::allocator > const, std::basic_string, std::allocator > >, Ogre::CategorisedAllocPolicy > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair, std::allocator > const, std::basic_string, std::allocator > >常量&)':
ogrewidget.cpp:(.text._ZNSt8_Rb_treeISsSt4pairIKSsSsESt10_Select1stIS2_ESt4lessISsEN4Ogre12STLAllocatorIS2_NS7_22CategorisedAllocPolicyILNS7_14MemoryCategoryE0EEEEEE10_M_insert_EPKSt18_Rb_tree_node_baseSG_RKS2_[std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::basic_string, std::allocator > >, std::_Select1st, std::allocator > const, std::basic_string, std::allocator > > >, std::less, std::allocator > >, Ogre::STLAllocator, std::allocator > const, std::basic_string, std ::allocator > >, Ogre::CategorisedAllocPolicy > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair, std::allocator > const, std::basic_string, std::分配器 > > const&)]+0x40): 未定义引用 `Ogre::NedPoolingImpl::allocBytes(unsigned int, char const*, int,字符常量*)'
ogrewidget.cpp:(.text._ZNSt8_Rb_treeISsSt4pairIKSsSsESt10_Select1stIS2_ESt4lessISsEN4Ogre12STLAllocatorIS2_NS7_22CategorisedAllocPolicyILNS7_14MemoryCategoryE0EEEEEE10_M_insert_EPKSt18_Rb_tree_node_baseSG_RKS2_[std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::basic_string, std::allocator > >, std::_Select1st, std::allocator > const, std::basic_string, std::allocator > > >, std::less, std::allocator > >, Ogre::STLAllocator, std::allocator > const, std::basic_string, std ::allocator > >, Ogre::CategorisedAllocPolicy > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair, std::allocator > const, std::basic_string, std::分配器 >> const&)]+0x10d): 未定义的对 `Ogre::NedPoolingImpl::deallocBytes(void*)' 的引用
ogrewidget.o: 在函数`std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::basic_string, std::allocator > >, std::_Select1st, std::分配器 > const, std::basic_string, std::allocator > > >, std::less, std::allocator > >, Ogre::STLAllocator, std::allocator > const, std::basic_string, std::allocator > >, Ogre::CategorisedAllocPolicy > >::_M_erase(std::_Rb_tree_node, std::allocator > const, std::basic_string, std::allocator > > >*)':
ogrewidget.cpp:(.text._ZNSt8_Rb_treeISsSt4pairIKSsSsESt10_Select1stIS2_ESt4lessISsEN4Ogre12STLAllocatorIS2_NS7_22CategorisedAllocPolicyILNS7_14MemoryCategoryE0EEEEEE8_M_eraseEPSt13_Rb_tree_nodeIS2_E[std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::basic_string, std::allocator > >, std::_Select1st, std::allocator > const, std::basic_string, std::allocator > > >, std::less, std::allocator > >, Ogre::STLAllocator, std::allocator > const, std::basic_string, std ::allocator > >, Ogre::CategorisedAllocPolicy > >::_M_erase(std::_Rb_tree_node, std::allocator > const, std::basic_string, std::allocator > > >*)]+0x47):未定义的引用`Ogre::NedPoolingImpl::deallocBytes(void*)'
collect2: ld 返回 1

什么可能导致这种情况,我该如何解决?

4

2 回答 2

3

您的内存分配器OgreBuildSettings.h可能并不反映 Ogre 实际构建的那个。将其更改为您构建 Ogre 时使用的那个(或者只是#define OGRE_MEMORY_ALLOCATOR使用OgreBuildSettings.h.

于 2010-03-22T22:52:50.267 回答
1

使用 QT4 和 Ogre Eihort 的示例 http://www.ogre3d.org/tikiwiki/QtOgre

在 ogrewidget.cpp 只需替换....

  // setup a renderer
  Ogre::RenderSystemList *renderers = mOgreRoot->getAvailableRenderers();
  assert( !renderers->empty() ); // we need at least one renderer to do anything useful

  Ogre::RenderSystem *renderSystem;
  renderSystem = chooseRenderer( renderers );

  assert( renderSystem ); // user might pass back a null renderer, which would be bad!

和....

  // setup a renderer
  Ogre::RenderSystemList::const_iterator renderers = mOgreRoot->getAvailableRenderers().begin();
  while(renderers != mOgreRoot->getAvailableRenderers().end())
  {
      Ogre::String rName = (*renderers)->getName();
        if (rName == "OpenGL Rendering Subsystem")
            break;
        renderers++;
  }

  Ogre::RenderSystem *renderSystem = *renderers;

它适用于 Ogre 1.7.3

要使用...

OgreWidget *ogreWidget = new OgreWidget();

于 2011-06-03T04:00:55.450 回答