在 Qt 中集成 OGRE 1.7

发布于 2024-08-23 05:50:08 字数 5303 浏览 10 评论 0原文

我需要将 Ogre 3d 集成到 Qt 4 中。我发现了一些代码和建议,不幸的是它们已经过时了。我喜欢这个教程

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

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

ogrewidget.o: In function `OgreWidget::~OgreWidget()':
ogrewidget.cpp:(.text+0x5b6): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `OgreWidget::~OgreWidget()':
ogrewidget.cpp:(.text+0x666): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `OgreWidget::~OgreWidget()':
ogrewidget.cpp:(.text+0x6f6): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `OgreWidget::initOgreSystem()':
ogrewidget.cpp:(.text+0x1cfb): undefined reference to `Ogre::NedPoolingImpl::allocBytes(unsigned int, char const*, int, char const*)'
ogrewidget.cpp:(.text+0x1dde): undefined reference to `Ogre::Root::initialise(bool, std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)'
ogrewidget.cpp:(.text+0x2278): undefined reference to `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): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `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::allocator > > const&)':
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::allocator > > const&)]+0x40): undefined reference to `Ogre::NedPoolingImpl::allocBytes(unsigned int, char const*, int, char const*)'
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::allocator > > const&)]+0x10d): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `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 > > >*)':
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): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
collect2: ld returned 1

可能会导致此错误的原因是什么以及如何解决它?

I need to integrate Ogre 3d in Qt 4. I found several codes and suggestions which are unfortunately out-dated. I liked this tutorial

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

It works with Ogre 1.4.9 (Eihorn) but not with the recent version 1.7.0. Compiling the app with the recent one results in a linker error

ogrewidget.o: In function `OgreWidget::~OgreWidget()':
ogrewidget.cpp:(.text+0x5b6): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `OgreWidget::~OgreWidget()':
ogrewidget.cpp:(.text+0x666): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `OgreWidget::~OgreWidget()':
ogrewidget.cpp:(.text+0x6f6): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `OgreWidget::initOgreSystem()':
ogrewidget.cpp:(.text+0x1cfb): undefined reference to `Ogre::NedPoolingImpl::allocBytes(unsigned int, char const*, int, char const*)'
ogrewidget.cpp:(.text+0x1dde): undefined reference to `Ogre::Root::initialise(bool, std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)'
ogrewidget.cpp:(.text+0x2278): undefined reference to `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): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `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::allocator > > const&)':
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::allocator > > const&)]+0x40): undefined reference to `Ogre::NedPoolingImpl::allocBytes(unsigned int, char const*, int, char const*)'
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::allocator > > const&)]+0x10d): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
ogrewidget.o: In function `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 > > >*)':
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): undefined reference to `Ogre::NedPoolingImpl::deallocBytes(void*)'
collect2: ld returned 1

What might cause this and how do I solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烂柯人 2024-08-30 05:50:08

OgreBuildSettings.h 的内存分配器可能并不反映 Ogre 实际构建时使用的内存分配器。将其更改为您构建 Ogre 时使用的值(或者只是使用 #define OGRE_MEMORY_ALLOCATOR 的数字。当您更新 Ogre 并忘记替换 OgreBuildSettings.h 时,就会发生这种情况替代包含路径(可能是您的项目的)。

The memory allocator of your OgreBuildSettings.h probably doesn't reflect the one Ogre was actually built with. Change it to the one used when you built Ogre (or just play with the numbers of #define OGRE_MEMORY_ALLOCATOR. It happens when you update Ogre and forget to replace OgreBuildSettings.h in an alternative include path (maybe your project's).

横笛休吹塞上声 2024-08-30 05:50:08

使用 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();

An Example using QT4 and Ogre Eihort
http://www.ogre3d.org/tikiwiki/QtOgre

In ogrewidget.cpp just replace....

  // 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!

With....

  // 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;

And it works with Ogre 1.7.3

To use...

OgreWidget *ogreWidget = new OgreWidget();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文