拽拽熊孩子 发表于 2016-12-26 08:11:49

osg帧率显示编译错误

代码是照着书上来的。结果出错了,代码如下:
#ifdef _DEBUG
#pragma comment(lib,"osgViewerd.lib")
#pragma comment(lib,"osgDBd.lib")
#pragma comment(lib,"OpenThreadsd.lib")
#pragma comment(lib,"osgd.lib")
#else
#pragma comment(lib,"osgViewer.lib")
#pragma comment(lib,"osgDB.lib")
#pragma comment(lib,"OpenThreads.lib")
#pragma comment(lib,"osg.lib")
#endif

#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/EventHandler>

int main()
{
        osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
        viewer->addEventHandler(new osgViewer::StatsHandler);
        viewer->setSceneData(osgDB::readNodeFile("glider.osg"));

        return viewer->run();
}

应该就是粗线那句出错,把他注释掉就没错了。
这是vs报的错误:
1>------ 已启动生成:项目: RateDisplay, 配置: Debug Win32 ------
1>main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual class osg::Object * __thiscall osgGA::GUIEventHandler::cloneType(void)const " (__imp_?cloneType@GUIEventHandler@osgGA@@UBEPAVObject@osg@@XZ),该符号在函数 ":public: virtual class osg::Object * __thiscall osgGA::GUIEventHandler::cloneType`vtordisp{4294967292,136}' (void)const " (?cloneType@GUIEventHandler@osgGA@@$4PPPPPPPM@II@BEPAVObject@osg@@XZ) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual class osg::Object * __thiscall osgGA::GUIEventHandler::clone(class osg::CopyOp const &)const " (__imp_?clone@GUIEventHandler@osgGA@@UBEPAVObject@osg@@ABVCopyOp@4@@Z),该符号在函数 ":public: virtual class osg::Object * __thiscall osgGA::GUIEventHandler::clone`vtordisp{4294967292,136}' (class osg::CopyOp const &)const " (?clone@GUIEventHandler@osgGA@@$4PPPPPPPM@II@BEPAVObject@osg@@ABVCopyOp@4@@Z) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall osgGA::GUIEventHandler::isSameKindAs(class osg::Object const *)const " (__imp_?isSameKindAs@GUIEventHandler@osgGA@@UBE_NPBVObject@osg@@@Z),该符号在函数 ":public: virtual bool __thiscall osgGA::GUIEventHandler::isSameKindAs`vtordisp{4294967292,136}' (class osg::Object const *)const " (?isSameKindAs@GUIEventHandler@osgGA@@$4PPPPPPPM@II@BE_NPBVObject@osg@@@Z) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual char const * __thiscall osgGA::GUIEventHandler::libraryName(void)const " (__imp_?libraryName@GUIEventHandler@osgGA@@UBEPBDXZ),该符号在函数 ":public: virtual char const * __thiscall osgGA::GUIEventHandler::libraryName`vtordisp{4294967292,136}' (void)const " (?libraryName@GUIEventHandler@osgGA@@$4PPPPPPPM@II@BEPBDXZ) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual char const * __thiscall osgGA::GUIEventHandler::className(void)const " (__imp_?className@GUIEventHandler@osgGA@@UBEPBDXZ),该符号在函数 ":public: virtual char const * __thiscall osgGA::GUIEventHandler::className`vtordisp{4294967292,136}' (void)const " (?className@GUIEventHandler@osgGA@@$4PPPPPPPM@II@BEPBDXZ) 中被引用
1>E:\vs2013\RateDisplay\Debug\RateDisplay.exe : fatal error LNK1120: 5 个无法解析的外部命令
========== 生成:成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========


osg编译的应该没问题,因为我运行 osgviewer cow.osg,能出来奶牛,也能按s显示帧率。新人小白一个,求大神帮忙看下是怎么回事?

phoenix_bpc 发表于 2017-3-10 09:23:45

osgGA的库路径好像没有配置
页: [1]
查看完整版本: osg帧率显示编译错误