对于OSG中需要不断给工程加入一些必要的静态库,但是如果没有找到全局的加入方法这里提供一种其他的解法:
因为之前已经在VS2012中加入了include的路径,意思就是它会自动搜索到这里来加入需要的头文件,那么可以把前面的一些静态库写成头文件的形式,这样的话加入也就非常方便。
1. 编写一个.h文件,包括以下内容:
#ifdef _DEBUG_ //release编译时的静态库
#pragma comment(lib,"OpenThreads.lib")
#pragma comment(lib,"osg.lib")
#pragma comment(lib,"osgDB.lib")
#pragma comment(lib,"osgFX.lib")
#pragma comment(lib,"osgGA.lib")
#pragma comment(lib,"osgManipulator.lib")
#pragma comment(lib,"osgParticle.lib")
#pragma comment(lib,"osgShadow.lib")
#pragma comment(lib,"osgSim.lib")
#pragma comment(lib,"osgTerrain.lib")
#pragma comment(lib,"osgText.lib")
#pragma comment(lib,"osgUtil.lib")
#pragma comment(lib,"osgViewer.lib")
#else //debug编译时的静态库
#pragma comment(lib,"OpenThreadsd.lib")
#pragma comment(lib,"osgd.lib")
#pragma comment(lib,"osgDBd.lib")
#pragma comment(lib,"osgFXd.lib")
#pragma comment(lib,"osgGAd.lib")
#pragma comment(lib,"osgManipulatord.lib")
#pragma comment(lib,"osgParticled.lib")
#pragma comment(lib,"osgShadowd.lib")
#pragma comment(lib,"osgSimd.lib")
#pragma comment(lib,"osgTerraind.lib")
#pragma comment(lib,"osgTextd.lib")
#pragma comment(lib,"osgUtild.lib")
#pragma comment(lib,"osgViewerd.lib")
#endif
2.将此头文件保存后,放到D:\OSG\OpenSceneGraph\include目录下即可。
3.然后每次写工程的时候加入头文件#include"osglib.h"就OK啦