Linux环境下OpenSceneGraph的安装和配置
1.在GitHub上下载OpenSceneGrpah的源码包,地址。
2.解压缩源码包并进入源码包;
3.安装所需的依赖库:
先输入命令:
sudo apt-get install openscenegraph
再次执行cmake . 后依然会提示缺少很多依赖库,依次手动安装:
egl:libgles2-mesa-dev
freetype:libfreetype6-dev
jpeg:libjpeg-dev
fltk:fltk1.3-dev
curl:libopenssl-dev
gstreamer:libgstreamer-plugins-base1.0-dev
gdal:libgdal-dev
sdl2:libsdl2-dev
sdl:libsdl1.2-dev
wxWidget:libwxgtk3.0-dev
tiff:libtiff-dev
用法:sudo apt install "package",将“package”替换为以上冒号后的库名即可。
4.再次执行以下命令:
cmake . make sudo make install
5.配置环境变量
在home路径下,编辑.bashrc。在文件末尾添加如下变量:
export PATH = “${PATH}:/home/junerain/project/OpenSceneGraph/bin” export LD_LIBRARY_PATH = “${LD_LIBRARY_PATH}:/home/junerain/project/OpenSceneGraph/lib” export OSG_FILE_PATH = “/home/**********/OpenSceneGraph-Data:/home/*********/OpenSceneGraph-Data/Images”
根据自己的电脑,将星号内容替换为下载的测试数据文件夹所在路径。之后执行source ./bashrc 使其生效。
6.测试
在命令行输入以下命令:
osgversion #yield "OpenSceneGraph Library 3.7.0" in my computer
osgviewer cow.osg #display a irony cow model
或和运行源码包自带的示例程序:
sh runexample.bat
即可看到许多有趣的例子。
Enjoy!