Ubuntu20.04 编译osg, osgearth

一:编译OSG

#sudo vim /etc/apt/sources.list 打开sources.list
#将sources.list里面的deb-src取消注释
#然后执行下面命令
sudo apt-get build-dep openscenegraph      
sudo apt-get install libgles2-mesa-dev libfreetype6-dev 
sudo apt-get install libjpeg-dev libgstreamer-plugins-base1.0-dev 
sudo apt-get install libgdal-dev libsdl2-dev libsdl1.2-dev libtiff-dev
sudo apt-get install zip unzip
sudo apt-get install build-essential pkg-config

#从https://github.com/openscenegraph/OpenSceneGraph 下载代码
#从https://github.com/openscenegraph/OpenSceneGraph-Data 下载样例数据
#然后执行下面命令

cur_path=$(pwd)

cd OpenSceneGraph

osg_path=${cur_path}/OpenSceneGraph

mkdir build
mkdir install 
cd build 
#cmake ..  -DOPENGL_PROFILE=GL3 -DOSG_GL_CONTEXT_VERSION=4.2 -DCMAKE_INSTALL_PREFIX=${osg_path}/install
cmake ..  -DCMAKE_INSTALL_PREFIX=${osg_path}/install
make -j8
make install 

export PATH=${PATH}:${osg_path}/install/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${osg_path}/install/lib
export OSG_FILE_PATH=${cur_path}/OpenSceneGraph-Data:${cur_path}/OpenSceneGraph-Data/Images 

osgviewer cow.osg

二:编译OSG_EARTH

#安装依赖库
sudo apt update 
sudo apt install build-essential 
sudo apt-get install libgdal-dev
sudo apt-get install libglew-dev
sudo apt-get install libspdlog-dev 
sudo apt-get install librocksdb-dev
sudo apt-get install libtinyxml-dev
sudo apt-get install libsqlite3-dev
sudo apt-get install libprotobuf-dev
sudo apt-get install libzip-dev
sudo apt-get install libwebp-dev
sudo apt-get install libgeos-dev
sudo apt-get install libblosc-dev
sudo apt-get install protobuf-compiler


#从https://github.com/gwaldron/osgearth下载代码

cd osgearth 
mkdir build 
cd build 
cmake ../ -DOSG_DIR=/your_path/osg/OpenSceneGraph/install -DCMAKE_INSTALL_PREFIX=/your_path/osg/osgearth/install
make -j8

make install

osg_path=/your_path/osg/OpenSceneGraph
osgearth_path=/your_path/osg/osgearth
osgearth_test=/your_path/osg/osgearth/tests

export PATH=${PATH}:${osg_path}/install/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${osg_path}/install/lib

export PATH=${PATH}:${osgearth_path}/install/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${osgearth_path}/install/lib64

osgearth_simple ${osgearth_test}/simple.earth

你可能感兴趣的:(三维引擎专栏,c++)