编译OSG
- 下载数据源
http://www.openscenegraph.org/downloads/stable_releases/
- 下载最全的(含full)第三方库
https://download.osgvisual.org/
- 官网下载源码
http://www.openscenegraph.org/index.php/download-section/stable-releases
- 下载cmake-gui
https://cmake.org/ - 新建OSG文件夹,将下载好的资源解压在OSG文件夹中。
新建INSTALL文件夹,用于编译成功后导出需要的include、lib、data,将三方库放在OSG文件夹下。 - 使用cmake生成vs解决方案(根据需要进行选择)
点击Configue,进行相关配置。
我是按照如上配置进行的,再点击Configue
这个不管了。下面的我也未处理。
64 bit architecture detected
searching TIFF -->tiff.h<-->libtiff<-->F:/OSG/3rdparty<--
searching FREETYPE -->ft2build.h<-->freetype;freetype2311MT;freetype234;freetype234MT;freetype235;freetype237;freetype238;freetype244;freetype250;<-->F:/OSG/3rdparty<--
searching CURL -->curl/curl.h<-->libcurl;curllib<-->F:/OSG/3rdparty<--
searching JPEG -->jpeglib.h<-->libjpeg;jpeg<-->F:/OSG/3rdparty<--
searching GDAL -->gdal.h<-->gdal;gdal16<-->F:/OSG/3rdparty<--
searching GLUT -->GL/glut.h<-->glut32<-->F:/OSG/3rdparty<--
searching GIFLIB -->gif_lib.h<-->ungif;libungif;giflib<-->F:/OSG/3rdparty<--
searching ZLIB -->zlib.h<-->z;zlib;zlib1<-->F:/OSG/3rdparty<--
searching PNG -->png.h<-->libpng;libpng13;libpng15;libpng16<-->F:/OSG/3rdparty<--
searching LIBXML2 -->libxml2<-->libxml2<-->F:/OSG/3rdparty<--
Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR)
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Could NOT find GStreamer (missing: GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES GSTREAMER_VERSION GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES GSTREAMER_APP_INCLUDE_DIRS GSTREAMER_APP_LIBRARIES GSTREAMER_PBUTILS_INCLUDE_DIRS GSTREAMER_PBUTILS_LIBRARIES)
Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Found unsuitable Qt version "" from NOTFOUND
Could NOT find Qt3 (missing: QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE)
Could NOT find FLTK (missing: FLTK_LIBRARIES FLTK_INCLUDE_DIR FLTK_FLUID_EXECUTABLE)
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS)
Configuring done
点击Generate,很快会提示Generating done。
7. 选择对应版本的VS打开项目,进行编译。
选择OpenSceneGraph解决方案,右键选择“批生成”
选择ALL_BUILD的Release(可以根据需要选择),点击生成。编译需要3个小时左右,编译完成后,取消ALL_BUILD的Release的选择,重新选择INSTALL的Release,点击生成,这个快。
生成完成之后,在INSTALL的文件下就会出现include、bin、lib等文件夹。
编译OSGEarth
1.在F盘新建文件件,OSG3.4.0,将3rdarty和编译好的OSG全部放在这个文件夹下,将data也放在该文件夹下。
2.配置环境变量
OSG_FILE_PATH:F:\OSG3.4.0\data
PATH:F:\OSG3.4.0\bin;F:\OSG3.4.0\share\OpenSceneGraph\bin
3.将CMakeLists.txt拖入,Cmake中,点击Configue
4.检查全部三方配置,有的都配置好,记得配置INSTALL。
把LINKER后面的内容去掉。再次点击Configue
Could not find ROCKSDB
Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
Set GLCORE_ROOT as the parent of the directory containing the OpenGL core profile header. (missing: GLCORE_INCLUDE_DIR)
Plugins will be installed under osgPlugins-3.4.0 directory.
Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
Configuring done
5.点击Generate,生成源码。使用对应的VS打开OSGEARTH项目。
选择OSGEARTH解决方案,右键选择“批生成”
选择ALL_BUILD的Release(可以根据需要选择),点击生成。编译需要2个小时左右,编译完成后,取消ALL_BUILD的Release的选择,重新选择INSTALL的Release,点击生成,这个快。
6.CMD验证。
验证OSG:osgviewer cow.osg
验证OSGEarth:osgviewer simple.earth
7.新建C++项目验证。
配置“链接器”=》“输入”=》“附加依赖项”
OpenThreads.lib
osg.lib
osgDB.lib
osgUtil.lib
osgGA.lib
osgFX.lib
osgViewer.lib
osgText.lib
osgdb_osgearth_feature_ogr.lib
osgdb_osgearth_feature_tfs.lib
osgdb_osgearth_feature_wfs.lib
osgEarth.lib
osgEarthAnnotation.lib
osgEarthFeatures.lib
osgEarthSymbology.lib
osgEarthUtil.lib
osgSim.lib
osgShadow.lib
osgManipulator.lib
osgWidget.lib
osgVolume.lib
osgUI.lib
osgTerrain.lib
osgPresentation.lib
osgParticle.lib
osgEarthSplat.lib
osgAnimation.lib
int main()
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("cow.osg"));
return viewer.run();
}
int main()
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("simple.earth"));
return viewer.run();
}
收工!待续C#的exe调试C++COM组件。