我正在尝试使用OpenSceneGraph。我已经使用CMake和Visual Studio 2013 X64来编译源代码。现在,我想建立一个项目,但是出现以下错误:

Error   1   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl osgViewer::Viewer::Viewer(void)" (__imp_??0Viewer@osgViewer@@QEAA@XZ) referenced in function main  C:\Users\epsilon-pc\documents\visual studio 2013\Projects\osgtest2\osgtest2\mainApp.obj osgtest2

Error   2   error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __cdecl osgViewer::Viewer::setSceneData(class osg::Node *)" (__imp_?setSceneData@Viewer@osgViewer@@UEAAXPEAVNode@osg@@@Z) referenced in function main C:\Users\epsilon-pc\documents\visual studio 2013\Projects\osgtest2\osgtest2\mainApp.obj osgtest2

Error   3   error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual int __cdecl osgViewer::Viewer::run(void)" (__imp_?run@Viewer@osgViewer@@UEAAHXZ) referenced in function main   C:\Users\epsilon-pc\documents\visual studio 2013\Projects\osgtest2\osgtest2\mainApp.obj osgtest2

Error   4   error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl osgViewer::Viewer::`vbase destructor'(void)" (__imp_??_DViewer@osgViewer@@QEAAXXZ) referenced in function main    C:\Users\epsilon-pc\documents\visual studio 2013\Projects\osgtest2\osgtest2\mainApp.obj osgtest2

Error   5   error LNK1120: 4 unresolved externals   C:\Users\epsilon-pc\documents\visual studio 2013\Projects\osgtest2\x64\Debug\osgtest2.exe   osgtest2


我已经添加了VC / C ++附加包含和链接器附加库目录和输入

osgGAd.lib;
osgFXd.lib;
osgUtild.lib;
osgd.lib;
osgDBd.lib;


这是我的代码(很简单):

#include <osgDB/ReadFile>
#include <osgViewer/Viewer>

int main(int argc, char** argv)
{
    osgViewer::Viewer viewer;
    viewer.setSceneData(osgDB::readNodeFile("cessna.osg"));
    return viewer.run();
}

最佳答案

在链接阶段,编译器没有找到osgViewer库;将osgViewerd.lib添加到链接库应该可以解决您的问题。让我知道它是否可以解决问题。

关于c++ - OpenSceneGraph LNK2019,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31773163/

10-13 05:44