c++ - 打开场景图 LNK2019 错误

标签 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 库没有包含某些东西(某处的 dll 或类似的),但我看不出我将如何解决这个问题。

任何和所有建议将不胜感激 - 虽然我确实需要尽快 sleep ,所以我可能不会立即回复。

最佳答案

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

关于c++ - 打开场景图 LNK2019 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23667772/

相关文章:

c++ - boost 的 "windows_shared_memory"和 boost 的 "managed_windows_shared_memory"有什么区别?

c++ - SDL 错误 LNK1120 & LNK2019

C++ LNK2019 错误 : Unresolved external symbol

c++ - Visual Studio 调试监视中的不同_fileName 值

c++ - "Include can' 找不到”,如何解决?

c++ - 如何环绕范围

c++ - 修改GradientFill API的RGB参数,避免代码修改

c++ - Lua、C++ 和消失的元表

c++ - 错误LNK2019是什么意思

c++ - 如何将纹理应用于 openscenegraph 中的模型?