标签:
环境:Vs2010
OpenSceneGraph-3.0.1-VS10.0.30319-x86-debug-12741
OpenSceneGraph-3.0.1-VS10.0.30319-x86-release-12741
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
void main()
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("glider.osg"));
viewer.realize();
viewer.run();
}
http://greatverve.cnblogs.com/archive/2012/09/19/osg-hello-world.html
编译出现的问题:d和非d的lib
过程中出现的问题:Microsoft C++ 异常 std::bad_alloc
0x7c812afb 处未处理的异常: Microsoft C++ 异常: 内存位置 0x0012f448 处的 std::bad_alloc。
原因:编译Debug版本的时候使用了不带d的Dll。
处理方法:
Demo编译成Debug版本使用带d的dll,编译成Release版本使用不带d的dll。
注意:
1. 编译Debug和Release版本需要分别设置项目属性中的包含目录文件和库目录。
2. 分别设置“链接器——输入——附加依赖项”,或者输入如下代码:
1 #ifdef _DEBUG
2 #pragma comment (lib,"OpenThreadsd.lib")
3 #pragma comment (lib,"osgd.lib")
4 #pragma comment (lib,"osgDBd.lib")
5 #pragma comment (lib,"osgFXd.lib")
6 #pragma comment (lib,"osgGAd.lib")
7 #pragma comment (lib,"osgManipulatord.lib")
8 #pragma comment (lib,"osgParticled.lib")
9 #pragma comment (lib,"osgShadowd.lib")
10 #pragma comment (lib,"osgSimd.lib")
11 #pragma comment (lib,"osgTerraind.lib")
12 #pragma comment (lib,"osgTextd.lib")
13 #pragma comment (lib,"osgUtild.lib")
14 #pragma comment (lib,"osgViewerd.lib")
15 #else
16 #pragma comment (lib,"OpenThreads.lib")
17 #pragma comment (lib,"osg.lib")
18 #pragma comment (lib,"osgDB.lib")
19 #pragma comment (lib,"osgFX.lib")
20 #pragma comment (lib,"osgGA.lib")
21 #pragma comment (lib,"osgManipulator.lib")
22 #pragma comment (lib,"osgParticle.lib")
23 #pragma comment (lib,"osgShadow.lib")
24 #pragma comment (lib,"osgSim.lib")
25 #pragma comment (lib,"osgTerrain.lib")
26 #pragma comment (lib,"osgText.lib")
27 #pragma comment (lib,"osgUtil.lib")
28 #pragma comment (lib,"osgViewer.lib")
29 # endif
标签:
原文地址:http://www.cnblogs.com/yhlx125/p/4248398.html