Build OSGEARTH On IOS

环境及准备

系统:macOS 10.13

Xcode:10.1

Cmake:3.11(https://cmake.org/download/)

OSG:3.6.1(http://www.openscenegraph.org/index.php/download-section/stable-releases)

OSGEarth:2.10(https://github.com/gwaldron/osgearth/tree/2.10)

3rdParty:https://pan.baidu.com/s/1Z9Hx912VOZgo4h8cgSiCRQ 密码:4tsk

步骤

step1

新建一个文档,将3rdParty、OSG、OSGEarth文件都放入


三个文档位于同一层级

打开Cmake,点击Tools--How to install For Command Line Use



建议选择第二个

开始编译OSG,这里说一下,OSG的文档写得很友好,打开里面的readme.md按照他的CMAKE Command就可以,如果想要用CmakeGUI一条一条设置也可以,但是最好设置一条就Configure一下,解决掉红色提醒后再Generate。

这里仅介绍使用终端以命令行方式去Build:

cd OpenSceneGraph3.6.1 path

   export THIRDPARTY_PATH=/path/to/my/3rdParty

    cmake ./ -G Xcode -DOSG_BUILD_PLATFORM_IPHONE:BOOL=ON \

    -DIPHONE_SDKVER="12.1" \

    -DIPHONE_VERSION_MIN="10.0" \

    -DOPENGL_PROFILE:STRING=GLES3 \

    -DBUILD_OSG_APPLICATIONS:BOOL=OFF \

    -DBUILD_OSG_EXAMPLES:BOOL=ON \

    -DOSG_WINDOWING_SYSTEM:STRING=IOS \

    -DOSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX="imageio" \

    -DDYNAMIC_OPENSCENEGRAPH:BOOL=OFF \

    -DDYNAMIC_OPENTHREADS:BOOL=OFF \

    -DOSG_CPP_EXCEPTIONS_AVAILABLE:BOOL=ON \

    -DCURL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/curl-ios-device/include" \

    -DCURL_LIBRARY:PATH="$THIRDPARTY_PATH/curl-ios-device/lib/libcurl.a" \

    -DFREETYPE_INCLUDE_DIR_freetype2:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include/freetype" \

    -DFREETYPE_INCLUDE_DIR_ft2build:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include" \

    -DFREETYPE_LIBRARY:PATH="$THIRDPARTY_PATH/freetype-ios-universal/lib/libFreetype2.a" \

    -DTIFF_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/tiff-ios-device/include" \

    -DTIFF_LIBRARY:PATH="$THIRDPARTY_PATH/tiff-ios-device/lib/libtiff.a" \

    -DGDAL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/gdal-ios-device/include" \

    -DGDAL_LIBRARY:PATH="$THIRDPARTY_PATH/gdal-ios-device/lib/libgdal.a"

cd 进你的OpenSceneGraph3.6.1文件夹,THIRDPARTY_PATH的路径就是你的3rdparty文件路径,IPHONE_SDKVER和IPHONE_VERSION_MIN可以按照你的Xcdoe版本自己设置,显示完成后打开OpenSceneGraph.xcodeproj,添加New Scheme,选择All Build,使用Release Build。如果需要跑OSG的DEMO,选择Target--example_osgViewerIPhone--Build Settings--Other Linker Flags--Release 删除oepngGl 以及上面的-framework,Build。

如果你用的是Xcode10以上,可能会在编译Pthread.cpp的时候报错,可以将错误的地方注释掉不影响编译,当然你也可以选择较低的Xcode版本,这样比较稳定


Step2

cd 进入osgearth文件夹,在终端输入以下命令:

export THIRDPARTY_PATH=/Users/zhcode/osgearthBuild/3rdParty

cmake ./ -G Xcode -DOSGEARTH_BUILD_PLATFORM_IPHONE:BOOL=ON \

-DIPHONE_SDKVER="12.1" \

-DIPHONE_VERSION_MIN="10.0" \

-DOSG_DIR:PATH="/Users/zhcode/osgearthBuild/OpenSceneGraph3.6.1" \

-DCURL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/curl-ios-device/include" \

-DCURL_LIBRARY:PATH="$THIRDPARTY_PATH/curl-ios-device/lib/libcurl.a" \

-DGDAL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/gdal-ios-device/include" \

-DGDAL_LIBRARY:PATH="$THIRDPARTY_PATH/gdal-ios-device/lib/libgdal.a" \

-DGEOS_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/geos-ios-device/include/source/headers" \

-DGEOS_LIBRARY:PATH="$THIRDPARTY_PATH/geos-ios-device/lib/libGEOS_3.2.a" \

-DPROJ_LIBRARY:PATH="$THIRDPARTY_PATH/proj4-ios-device/lib/libproj.a" \

-DFREETYPE_LIBRARY:PATH="$THIRDPARTY_PATH/freetype-ios-universal/lib/libFreetype2.a" \

-DOSGEARTH_BUILD_APPLICATION_BUNDLES:BOOL=ON \

-DBUILD_OSGEARTH_EXAMPLES:BOOL=ON \

-DDYNAMIC_OSGEARTH:BOOL=OFF

同样,将文件位置改为你自己的位置即可,打开project文件,选择文件----projectSetting---buildSystem 选择legacy build system,将build模式该为release,选择example目标build,静待完成。

你可能感兴趣的:(Build OSGEARTH On IOS)