C++ 在MSVS2012中使用osg标头时出现错误LNK2019未解析的外部符号
我正试图编写一个学习使用osg的示例程序,但通往成功的道路似乎一如既往地艰难 代码如下:C++ 在MSVS2012中使用osg标头时出现错误LNK2019未解析的外部符号,c++,lnk2019,unresolved-external,openscenegraph,C++,Lnk2019,Unresolved External,Openscenegraph,我正试图编写一个学习使用osg的示例程序,但通往成功的道路似乎一如既往地艰难 代码如下: #include <windows.h> #include <osgDB\ReadFile> #include <osgViewer\Viewer> int main() { osgViewer::Viewer viewer; viewer.setSceneData(osgDB::readNodeFile("cessna.osg")); return
#include <windows.h>
#include <osgDB\ReadFile>
#include <osgViewer\Viewer>
int main()
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("cessna.osg"));
return viewer.run();
}
到附加依赖项
还选择了调试模式
尝试编译时,我会遇到多个类似错误:
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
1>mainApp.obj:错误LNK2019:未解析的外部符号
“”\uu declspec(dllimport)public:静态类osgDB::Registry*\uu cdecl
osgDB::Registry::instance(bool)“(\u\u imp\u?instance@Registry@osgDB@@SAPAV12@_N@Z) "
在函数“”类osg::Node*\uu cdecl osgDB::readNodeFile中
(类标准::基本字符串常量&)
(?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@性病病毒?
$allocator@D@2@@std@@@Z)”
1> mainApp.obj:错误LNK2019:未解析的外部符号
“”\uuuu declspec(dllimport)public:class osgDB::Options*\uuu thiscall
osgDB::Registry::getOptions(void)“(\u\u imp\u?getOptions@Registry@osgDB@@QAEPAVOptions@2@XZ)“在
Funktion“”类osg::Node*\uU cdecl osgDB::readNodeFile(类std::基本字符串常量&)
(?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@@Z)”。
1> mainApp.obj:错误LNK2019:未解析的外部符号
“”\uuuu declspec(dllimport)类osg::Node*\uuuuu cdecl osgDB::readNodeFile(类
标准::基本字符串常量
&,类osgDB::Options const*)“(_uimp_?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@性病病毒?
$allocator@D@2@@std@@PBVOptions@1@@Z) “在Funktion”类osg::Node*\uu cdecl
osgDB::readNodeFile(类std::基本字符串常量&)
(?readNodeFile@osgDB@@YAPAVNode@osg@@ABV?$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@@Z)”。
1> mainApp.obj:错误LNK2019:未解析的外部符号
“”\u declspec(dllimport)public:\u此调用osgViewer::Viewer::Viewer::Viewer(void)”
(uuu imp_uu???)??0Viewer@osgViewer@@QAE@XZ)“在功能区”。
1> mainApp.obj:错误LNK2019:未解析的外部符号
“”\uuuu declspec(dllimport)public:virtual void \uuuu thiscall osgViewer::Viewer::setSceneData(类
osg::Node*)“(\uuuu imp\uu?setSceneData@Viewer@奥斯维耶@@UAEXPAVNode@osg@@@Z) “在功能区”。
1> mainApp.obj:错误LNK2019:未解析的外部符号
“”\uuu declspec(dllimport)public:virtual int \uuuu thiscall osgViewer::Viewer::run(void)
(uu_uimp_u)?run@Viewer@osgViewer@@UAEHXZ)“在Funktion”\u main中”。
1> mainApp.obj:错误LNK2019:外部符号
“”declspec(dllimport)public:void\u此调用osgViewer::Viewer::`vbase destructor'(void)
(uuu imp_uu???)_DViewer@osgViewer@@QAEXXZ)“在Funktion”_main中”。
1> C:\Users\Admin2\documents\visual studio 2012\Projects\osgTest\Debug\osgTest.exe:致命错误LNK1120:7 nicht aufgelöste Externe
(很抱歉代码中有一些德语表达,我尝试翻译了其中的大部分。)
有人知道怎么解决这个问题吗?
提前谢谢。我不知道这个库,但可能是32位与64位不匹配?但我怎么才能发现呢?首先,您是否运行64位Windows?如果是这样,请将您的项目更改为针对64位Windows构建,然后重试。最后,这就是解决方案。我真丢脸。但是谢谢你提醒我这么简单的事情。
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