osg 编译笔记 - guangmushikong/CatEyeEarth GitHub Wiki

时间

2017年11月8日

参考

osg 官方文档: http://www.openscenegraph.org/index.php/documentation/platform-specifics/ios/216-generating-an-ios-xcode-project-2017

环境与关键工具

  • 系统 macOS Sierra (10.12.6)

  • Xcode

    • Version 8.3.3 (8E3004b)
    • CXX Compiler: AppleClang 8.1.0.8020042
  • CMake

依赖库 Fat 文件

链接:http://pan.baidu.com/s/1qY6xGMK 密码:v3ok

步骤

  1. 代码 Download OSG trunk
cd /Users/wangmiao/projects/osgearth-build/osg-ios/
git clone https://github.com/openscenegraph/OpenSceneGraph.git

code version: commit ad45bf1d616816413f490c3eb116928a56db36ba Author: Robert Osfield [email protected] Date: Mon Oct 16 11:52:54 2017 +0100

  1. cmake 运行
export THIRDPARTY_PATH=/Volumes/mac/Cateye/3rdParty
export IPHONE_SDK_USR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr
/Applications/CMake.app/Contents/bin/cmake ./ -G Xcode -DOSG_BUILD_PLATFORM_IPHONE:BOOL=ON \
-DIPHONE_SDKVER="10.3" \
-DIPHONE_VERSION_MIN="8.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" \
-DOSG_GL1_AVAILABLE:BOOL=OFF \
-DOSG_GL2_AVAILABLE:BOOL=OFF \
-DOSG_GLES1_AVAILABLE:BOOL=OFF \
-DOSG_GLES2_AVAILABLE:BOOL=OFF \
-DOSG_GLES3_AVAILABLE:BOOL=ON \
-DDYNAMIC_OPENSCENEGRAPH:BOOL=OFF \
-DDYNAMIC_OPENTHREADS:BOOL=OFF \
-DZLIB_INCLUDE_DIR:PATH="$IPHONE_SDK_USR/include" \
-DZLIB_LIBRARY:PATH="$IPHONE_SDK_USR/lib/libz.tbd" \
-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/libFreeType_iphone_universal.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"
  1. xcode 工程编译 3.1 打开xcode 3.2 选择目标 example_osgViewerIPhone

设置: In the 'Build Settings' tab search for 'Other Linker Flags', then for each target type (debug, release etc) that you want to use open the list of arguments and delete the 'OpenGL' line and the '-framework' line above it. This is because cmake has tried to add the desktop OpenGL library which we don't want.

-lz

选择 iOS Deployment Target : 10.3

3.3 选择设备 真机调试,连接真机 build即可。

QQ20171024-0.png

  1. next: OSGEarth 为了编译 osgEarth,还需要编译其他库,其中 osgdb_fastdxt 编译会有语法错误,且 osgEarth用不着,可以去掉。