Question

I'm working on a C++ assignment (C++98 & VS2010) using OSG and a pre-built template project to work on. I'm trying to implement mouse picking using the osgUtil/LineSegementIntersector and osgUtil/IntersectionVisitor classes. Unfortunately when I run this code I get a bunch of LNK2001 and LNK2019 errors. The two classes are included at the top of the file, the folder with the osg libraries is included in the linker and the osgUtild.lib file is present in the directory.

The Code:

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++)
        { 
        }
    }
}

The Errors:

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

I can't see anything wrong with my code or my setup, my only thoughts at the moment based on everything I've read is that there's something not being included (a dll somewhere or similar) by the osgUtil library but I can't see how I would be able to resolve that.

Any and all advice would be appreciated - though I definitely require sleep soon so I may not respond immediately.

Was it helpful?

Solution

Dlls are not included at compile time. Specifying the folder only is not sufficient. you need to specify that you are going to use OsgUtild.lib explicitly to linker.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top