|
目前正在学习OSG,手头的两本教材就是FreeSouth的《OpenSceneGraph设计教程》和Array的《OpenSceneGraph三维渲染引擎设计与指南》,但一上手就遇到了几个问题,下面分别把代码考上来并有附件,希望得到大侠的指导,因为这几个问题已经困扰了我10天了,有点崩溃!
// 下面的这个例子是FreeSouth书中的第五个例子:
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/Node>
void main()
{
osgViewer::Viewer viewer;
osg::Group * root = new osg::Group();
root->addChild(osgDB::readNodeFile("lider.osg"));
root->addChild(osgDB::readNodeFile("osgcool.osg"));
viewer.setSceneData(root);
viewer.realize();
viewer.run();
}
结果,编译通过,但是运行时程序出现异常Unhandled exception at 0x7c812afb in Example5.exe: Microsoft C++ exception: __non_rtti_object @ 0x0012fac0.程序停在了dHeap.c中的这个函数出:
_CRTIMP void * __cdecl malloc (
size_t nSize
)
{
void *res = _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));
return res;
}
// 下面的这个例子是Array书中的第二个例子:
#include <osg/Node>
#include <osgDB/ReadFile>
#include <iostream>
class InfoVisitor : public osg::NodeVisitor
{
public:
InfoVisitor()sg::NodeVisitor(TRAVERSE_ALL_CHILDREN), _indent(0){}
virtual void apply(osg::Node& node)
{
for(int i = 0; i < _indent; i++)
std::cout << " ";
std::cout << "[" << _indent << "]" << node.libraryName() << "::" << node.className() << std::endl;
_indent++;
traverse(node);
_indent--;
}
virtual void apply(osg::Geode& node)
{
for(int i = 0; i < _indent; i++)
std::cout << " ";
std::cout << "[" << _indent << "]" << node.libraryName() << "::" << node.className() << std::endl;
for(unsigned int n = 0; n < node.getNumDrawables(); ++n)
{
osg:rawable* drawable = node.getDrawable(n);
if(!drawable)
continue;
for(int i = 0; i <= _indent; i++)
std::cout << " ";
std::cout << drawable->libraryName() << "::" << drawable->className() << std::endl;
}
_indent++;
traverse(node);
_indent--;
}
protected:
int _indent;
};
void main(int argc, char**argv)
{
osg::ArgumentParser arguments(&argc, argv);
osg::Node* root = osgDB::readNodeFiles(arguments);
if(!root)
root = osgDB::readNodeFile("axes.osg");
InfoVisitor infoVisitor;
if(root)
root->accept(infoVisitor);
}
结果,编译通过,运行时出现下面的链接错误
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > & (__cdecl*)(class std::basic_ostream<char,struct std::char_traits<char> > &))" ([email=__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z]__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z[/email]) referenced in function "public: virtual void __thiscall InfoVisitor::apply(class osg::Node &)" ([email=?apply@InfoVisitor@@UAEXAAVNode@osg@@@Z]?apply@InfoVisitor@@UAEXAAVNode@osg@@@Z[/email])
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(int)" ([email=__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z]__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z[/email]) referenced in function "public: virtual void __thiscall InfoVisitor::apply(class osg::Node &)" ([email=?apply@InfoVisitor@@UAEXAAVNode@osg@@@Z]?apply@InfoVisitor@@UAEXAAVNode@osg@@@Z[/email])
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" ([email=__imp_?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ]__imp_?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ[/email]) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" ([email=?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z]?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z[/email])
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::put(char)" ([email=__imp_?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z]__imp_?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z[/email]) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" ([email=?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z]?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z[/email])
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " ([email=__imp_?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ]__imp_?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ[/email]) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" ([email=??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z]??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z[/email])
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " ([email=__imp_?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ]__imp_?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ[/email]) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" ([email=??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z]??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z[/email])
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " ([email=__imp_?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ]__imp_?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ[/email]) referenced in function "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits<char> > &)" ([email=??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@AAV12@@Z]??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@AAV12@@Z[/email])
Example3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" ([email=__imp_?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ]__imp_?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ[/email]) referenced in function "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)" ([email=??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ]??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ[/email])
Debug/Example3.exe : fatal error LNK1120: 8 unresolved externals
Build log was saved at "file://e:\OpenSceneGraph\osg-practice\Array\Example3\Debug\BuildLog.htm"
Example3 - 9 error(s), 72 warning(s)
肯定得到大侠的指点,不胜感激! |
|