打开场景图LNK2019错误

时间:2014-05-15 01:24:23

标签: c++ lnk2019 openscenegraph

我正在使用OSG和预先构建的模板项目进行C ++任务(C ++ 98& VS2010)。我尝试使用osgUtil / LineSegementIntersector和osgUtil / IntersectionVisitor类来实现鼠标拾取。不幸的是,当我运行此代码时,我得到了一堆LNK2001和LNK2019错误。这两个类包含在文件的顶部,带有osg库的文件夹包含在链接器中,osgUtild.lib文件存在于目录中。

守则:

osgViewer::Viewer *pViewer=dynamic_cast<osgViewer::Viewer*>(aa.asView());
osgUtil::LineSegmentIntersector* picker;
picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, ea.getXnormalized(), ea.getYnormalized());
osgUtil::IntersectionVisitor iv(picker);
pViewer->getCamera()->accept(iv);
if(picker->containsIntersections())
{
    osgUtil::LineSegmentIntersector::Intersections intersections = picker->getIntersections();
    for(osgUtil::LineSegmentIntersector::Intersections::iterator it = intersections.begin(); it != intersections.end(); it++)
    {
        for(NodePath::const_reverse_iterator rit = it->nodePath.rbegin(); rit != it->nodePath.rend(); rit++)
        { 
        }
    }
}

错误:

1>raaOSGSimpleEventHandler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall osgUtil::IntersectionVisitor::`vbase destructor'(void)" (__imp_??_DIntersectionVisitor@osgUtil@@QAEXXZ) referenced in function "public: virtual bool __thiscall raaOSGSimpleEventHandler::handle(class osgGA::GUIEventAdapter const &,class osgGA::GUIActionAdapter &,class osg::Object *,class osg::NodeVisitor *)" (?handle@raaOSGSimpleEventHandler@@UAE_NABVGUIEventAdapter@osgGA@@AAVGUIActionAdapter@3@PAVObject@osg@@PAVNodeVisitor@6@@Z)
1>raaOSGSimpleEventHandler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::multiset<struct osgUtil::LineSegmentIntersector::Intersection,struct std::less<struct osgUtil::LineSegmentIntersector::Intersection>,class std::allocator<struct osgUtil::LineSegmentIntersector::Intersection> > & __thiscall osgUtil::LineSegmentIntersector::getIntersections(void)" (__imp_?getIntersections@LineSegmentIntersector@osgUtil@@QAEAAV?$multiset@UIntersection@LineSegmentIntersector@osgUtil@@U?$less@UIntersection@LineSegmentIntersector@osgUtil@@@std@@V?$allocator@UIntersection@LineSegmentIntersector@osgUtil@@@5@@std@@XZ) referenced in function "public: virtual bool __thiscall raaOSGSimpleEventHandler::handle(class osgGA::GUIEventAdapter const &,class osgGA::GUIActionAdapter &,class osg::Object *,class osg::NodeVisitor *)" (?handle@raaOSGSimpleEventHandler@@UAE_NABVGUIEventAdapter@osgGA@@AAVGUIActionAdapter@3@PAVObject@osg@@PAVNodeVisitor@6@@Z)
1>raaOSGSimpleEventHandler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall osgUtil::IntersectionVisitor::IntersectionVisitor(class osgUtil::Intersector *,struct osgUtil::IntersectionVisitor::ReadCallback *)" (__imp_??0IntersectionVisitor@osgUtil@@QAE@PAVIntersector@1@PAUReadCallback@01@@Z) referenced in function "public: virtual bool __thiscall raaOSGSimpleEventHandler::handle(class osgGA::GUIEventAdapter const &,class osgGA::GUIActionAdapter &,class osg::Object *,class osg::NodeVisitor *)" (?handle@raaOSGSimpleEventHandler@@UAE_NABVGUIEventAdapter@osgGA@@AAVGUIActionAdapter@3@PAVObject@osg@@PAVNodeVisitor@6@@Z)
1>raaOSGSimpleEventHandler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall osgUtil::LineSegmentIntersector::LineSegmentIntersector(enum osgUtil::Intersector::CoordinateFrame,double,double)" (__imp_??0LineSegmentIntersector@osgUtil@@QAE@W4CoordinateFrame@Intersector@1@NN@Z) referenced in function "public: virtual bool __thiscall raaOSGSimpleEventHandler::handle(class osgGA::GUIEventAdapter const &,class osgGA::GUIActionAdapter &,class osg::Object *,class osg::NodeVisitor *)" (?handle@raaOSGSimpleEventHandler@@UAE_NABVGUIEventAdapter@osgGA@@AAVGUIActionAdapter@3@PAVObject@osg@@PAVNodeVisitor@6@@Z)
1>raaOSGSimpleEventHandler.obj : error LNK2001: unresolved external symbol "public: virtual class osgUtil::Intersector * __thiscall osgUtil::LineSegmentIntersector::clone(class osgUtil::IntersectionVisitor &)" (?clone@LineSegmentIntersector@osgUtil@@UAEPAVIntersector@2@AAVIntersectionVisitor@2@@Z)
1>raaOSGSimpleEventHandler.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall osgUtil::LineSegmentIntersector::enter(class osg::Node const &)" (?enter@LineSegmentIntersector@osgUtil@@UAE_NABVNode@osg@@@Z)
1>raaOSGSimpleEventHandler.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall osgUtil::LineSegmentIntersector::leave(void)" (?leave@LineSegmentIntersector@osgUtil@@UAEXXZ)
1>raaOSGSimpleEventHandler.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall osgUtil::LineSegmentIntersector::intersect(class osgUtil::IntersectionVisitor &,class osg::Drawable *)" (?intersect@LineSegmentIntersector@osgUtil@@UAEXAAVIntersectionVisitor@2@PAVDrawable@osg@@@Z)
1>raaOSGSimpleEventHandler.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall osgUtil::LineSegmentIntersector::reset(void)" (?reset@LineSegmentIntersector@osgUtil@@UAEXXZ)
1>raaOSGSimpleEventHandler.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall osgUtil::LineSegmentIntersector::containsIntersections(void)" (?containsIntersections@LineSegmentIntersector@osgUtil@@UAE_NXZ)
1>raaOSGSimpleEventHandler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall osgUtil::LineSegmentIntersector::~LineSegmentIntersector(void)" (__imp_??1LineSegmentIntersector@osgUtil@@UAE@XZ) referenced in function "public: virtual void * __thiscall osgUtil::LineSegmentIntersector::`scalar deleting destructor'(unsigned int)" (??_GLineSegmentIntersector@osgUtil@@UAEPAXI@Z)
1>D:\raaOSG(1)\raaOSG\raaOSGResource\Debug\raaOSGSimpleDemoD.exe : fatal error LNK1120: 11 unresolved externals

我无法看到我的代码或设置有任何问题,我目前根据我所读过的所有内容的唯一想法是,没有包含某些内容(某个地方或某个地方或类似的)osgUtil库,但我不知道如何解决这个问题。

任何和所有建议都会受到赞赏 - 虽然我很快就要求睡觉,所以我可能不会立即回复。

1 个答案:

答案 0 :(得分:1)

编译时不包含Dll。仅指定文件夹是不够的。您需要指定将明确地将OsgUtild.lib用于链接器。