查看: 1227|回复: 2

osgFX::Scribe编译不通过问题

[复制链接]

该用户从未签到

发表于 2014-5-16 19:35:57 | 显示全部楼层 |阅读模式
这是杨石兴大哥书上的,可是我生成成功,运行不了,不知道怎么回事,求帮忙啊
  1. #include <iostream>
  2. #include <osgDB/ReadFile>
  3. #include <osgViewer/Viewer>
  4. #include <osg/Group>
  5. #include <osg/Node>
  6. #include <osgFX/Scribe>
  7. #include <osgGA/GUIEventHandler>
  8. #include <osgUtil/LineSegmentIntersector>

  9. class CPickHandler:public osgGA::GUIEventHandler
  10. {
  11. public:
  12.     CPickHandler(osgViewer::Viewer * viewer):mViewer(viewer){};
  13.     virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &&aa)
  14.     {
  15.         switch(ea.getEventType())
  16.         {
  17.             // PUSH, button down
  18.         case osgGA::GUIEventAdapter::PUSH:
  19.             // 1,left button push
  20.             if (ea.getButton()==1)
  21.             {
  22.                 Pick(ea.getX(),ea.getY());
  23.             }
  24.             return true;
  25.         }
  26.         return false;
  27.     }
  28. protected:
  29.     void Pick(float x, float y)
  30.     {
  31.         osgUtil::LineSegmentIntersector::Intersections intersections;
  32.         if (mViewer->computeIntersections(x,y,intersections))
  33.         {
  34.             for (osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
  35.                 hitr != intersections.end();
  36.                 ++ hitr)
  37.             {
  38.                 if (! hitr->nodePath.empty() && ! (hitr->nodePath.back()->getName().empty()))
  39.                 {
  40.                     const osg::NodePath &np = hitr->nodePath;
  41.                     for(int i = np.size()-1;i>=0;--i)
  42.                     {
  43.                         osgFX::Scribe *sc = dynamic_cast<osgFX::Scribe *> (np[i]);
  44.                         if(sc!=NULL)
  45.                         {
  46.                             if(sc->getNodeMask()!=0)
  47.                                 sc->setNodeMask(0);
  48.                         }
  49.                     }
  50.                 }

  51.             }
  52.         }
  53.     }
  54.     osgViewer::Viewer *mViewer;
  55. };


  56. // argc: the number of argv
  57. // argv: an array of arguments,
  58. //       args[0] always is the path and name of the program itself.
  59. int main(int argc, char** argv)
  60. {

  61.     osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();

  62.     osg::ref_ptr<osg::Group>  root = new osg::Group();
  63.     root->addChild(osgDB::readNodeFile("cessna.osg"));
  64.     osg::ref_ptr<osg::Node> cow = osgDB::readNodeFile("cow.osg");

  65.     osg::ref_ptr<osgFX::Scribe> sc = new osgFX::Scribe();
  66.     sc->addChild(cow.get());
  67.    
  68.     root->addChild(cow.get());
  69.     root->addChild(sc.get());
  70.    
  71.     viewer->setSceneData(root.get());

  72.     viewer->addEventHandler(new CPickHandler(viewer.get()));

  73.     viewer->realize();
  74.     viewer->run();


  75. }
复制代码


系统提示:
  1. 1>  所有输出均为最新。
  2. 1>pick.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall osgFX::Scribe::Scribe(void)" (__imp_??0Scribe@osgFX@@QAE@XZ)
  3. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Object * __thiscall osgFX::Scribe::cloneType(void)const " (?cloneType@Scribe@osgFX@@UBEPAVObject@osg@@XZ)
  4. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Object * __thiscall osgFX::Scribe::clone(class osg::CopyOp const &)const " (?clone@Scribe@osgFX@@UBEPAVObject@osg@@ABVCopyOp@4@@Z)
  5. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osgFX::Scribe::isSameKindAs(class osg::Object const *)const " (?isSameKindAs@Scribe@osgFX@@UBE_NPBVObject@osg@@@Z)
  6. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osgFX::Scribe::libraryName(void)const " (?libraryName@Scribe@osgFX@@UBEPBDXZ)
  7. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osgFX::Scribe::className(void)const " (?className@Scribe@osgFX@@UBEPBDXZ)
  8. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osgFX::Scribe::accept(class osg::NodeVisitor &)" (?accept@Scribe@osgFX@@UAEXAAVNodeVisitor@osg@@@Z)
  9. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osgFX::Effect::traverse(class osg::NodeVisitor &)" (?traverse@Effect@osgFX@@UAEXAAVNodeVisitor@osg@@@Z)
  10. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osgFX::Scribe::effectName(void)const " (?effectName@Scribe@osgFX@@UBEPBDXZ)
  11. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osgFX::Scribe::effectDescription(void)const " (?effectDescription@Scribe@osgFX@@UBEPBDXZ)
  12. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osgFX::Scribe::effectAuthor(void)const " (?effectAuthor@Scribe@osgFX@@UBEPBDXZ)
  13. 1>pick.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osgFX::Effect::setUpDemo(void)" (?setUpDemo@Effect@osgFX@@UAEXXZ)
  14. 1>pick.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __thiscall osgFX::Scribe::define_techniques(void)" (?define_techniques@Scribe@osgFX@@MAE_NXZ)
  15. 1>pick.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) protected: virtual __thiscall osgFX::Scribe::~Scribe(void)" (__imp_??1Scribe@osgFX@@MAE@XZ)
  16. 1>D:\我的C++\pick\Debug\pick.exe : fatal error LNK1120: 14 个无法解析的外部命令
  17. 1>
  18. 1>生成失败。
复制代码

该用户从未签到

发表于 2014-5-18 21:36:31 | 显示全部楼层
#pragma comment(lib,"osgFX.lib")  or  #pragma comment(lib,"osgFXd.lib")

该用户从未签到

 楼主| 发表于 2014-5-27 10:30:15 | 显示全部楼层
tubyvr 发表于 2014-5-18 21:36
#pragma comment(lib,"osgFX.lib")  or  #pragma comment(lib,"osgFXd.lib")

已经好了,谢谢你~~~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表