我正在尝试编译一个示例程序来学习使用 osg,但通往成功的道路似乎一如既往地艰难。
这是代码:
#include <windows.h>
#include <osgDB\ReadFile>
#include <osgViewer\Viewer>
int main()
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("cessna.osg"));
return viewer.run();
}
我添加C:\Program Files\OpenSceneGraph-3.2.0\include
到Additional Include Directories
. 此外,我添加C:\Program Files\OpenSceneGraph-3.2.0\lib
到Additional Library Directories
和
osgd.lib;
osgViewerd.lib;
osgDBd.lib;
osgFXd.lib;
osgGAd.lib;
osgUtild.lib;
%(AdditionalDependencies)
到Additional Dependecies
.
还选择了调试模式。
尝试编译时出现多个类似错误:
1>mainApp.obj : error LNK2019: unresolved external symbol
""__declspec(dllimport) public: static class osgDB::Registry * __cdecl
osgDB::Registry::instance(bool)" (__imp_?instance@Registry@osgDB@@SAPAV12@_N@Z)"
in function ""class osg::Node * __cdecl osgDB::readNodeFile
(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"
(?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@@Z)"
1>mainApp.obj : error LNK2019: unresolved external symbol
""__declspec(dllimport) public: class osgDB::Options * __thiscall
osgDB::Registry::getOptions(void)" (__imp_?getOptions@Registry@osgDB@@QAEPAVOptions@2@XZ)" in
Funktion ""class osg::Node * __cdecl osgDB::readNodeFile(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const &)"
(?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@@Z)".
1>mainApp.obj : error LNK2019: unresolved external symbol
""__declspec(dllimport) class osg::Node * __cdecl osgDB::readNodeFile(class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const
&,class osgDB::Options const *)" (__imp_?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@PBVOptions@1@@Z)" in Funktion ""class osg::Node * __cdecl
osgDB::readNodeFile(class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const &)"
(?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@@Z)".
1>mainApp.obj : error LNK2019: unresolved external symbol
""__declspec(dllimport) public: __thiscall osgViewer::Viewer::Viewer(void)"
(__imp_??0Viewer@osgViewer@@QAE@XZ)" in Funktion "_main".
1>mainApp.obj : error LNK2019: unresolved external symbol
""__declspec(dllimport) public: virtual void __thiscall osgViewer::Viewer::setSceneData(class
osg::Node *)" (__imp_?setSceneData@Viewer@osgViewer@@UAEXPAVNode@osg@@@Z)" in Funktion "_main".
1>mainApp.obj : error LNK2019: unresolved external symbol
""__declspec(dllimport) public: virtual int __thiscall osgViewer::Viewer::run(void)"
(__imp_?run@Viewer@osgViewer@@UAEHXZ)" in Funktion "_main".
1>mainApp.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol
""__declspec(dllimport) public: void __thiscall osgViewer::Viewer::`vbase destructor'(void)"
(__imp_??_DViewer@osgViewer@@QAEXXZ)" in Funktion "_main".
1>C:\Users\Admin2\documents\visual studio 2012\Projects\osgTest\Debug\osgTest.exe : fatal error LNK1120: 7 nicht aufgelöste Externe
(对于代码中的一些德语表达,我很抱歉,我试图翻译其中的大部分。)
有谁知道如何解决这个问题?提前致谢。