osg for android 编译,osgEarth - How to compile osgearth for android

本文围绕OSGEarth for Android编译展开,介绍了使用cmake编译时采用OSGGLES2参数,将osgEarth和osg源码一起编译,不建议修改osg cmakelists。还提及处理编译不过的CPP文件的方法,以及运行时提示加载纹理问题,有人建议检查OpenGL ES版本并分享cmake配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Forehead, I use cmake is using OSGGLES2 parameters, the specific approach is to throw the osgEarth and osg source together, it is best not to change osg cmakelists, then such cmake is ok, if you download the osgEarth - topic - android can direct production. Mk file, but generated after covering once and it is better to use 2.4 source code modification. Mk file, because the generated will contain fewer files directly. How do some of the CPP can not compile in the past, I was directly from. Delete the mk. See the error message when make, the add of add, delete to delete, you can also modify. Mk to compile only osgEarth. The strange thing is if you don't throw the osgearth osg cannot compile in the past, the reason is unknown.

Now my question is, libNative. So have been generated, but the running time is not prompt "Couldn 't load moon texture, add osgEarth' s data directory your OSG_FILE

At 2013-07-23 01:55:57,"xuhaiyan8825 [via osgEarth]"  wrote:

cool,nice done!

maybe you can check your opengles version.

could you share us your cmake configuration?

To unsubscribe from How to compile osgearth for android, click here.

NAML

### 编译 osgEarthAndroid 平台 对于在 Android编译 osgEarth 的需求,虽然官方文档可能未提供直接针对此操作系统的指南,但可以借鉴其他开源项目以及社区贡献者的经验来完成这一过程。 #### 准备工作 确保已安装并配置好适用于 Android 开发的 Qt6 环境[^2]。这一步至关重要,因为后续的操作依赖于此环境所提供的工具链和支持库。 #### 获取源码 从 GitHub 或者其它托管服务下载最新的 osgEarth 源代码仓库。注意选择稳定分支或者特定标签以获得经过测试验证过的版本。 #### 修改 CMakeLists.txt 文件适应 Android 构建体系 由于默认情况下 CMake 脚本可能是面向桌面平台准备的,在尝试为移动设备构建之前需调整 `CMakeLists.txt` 中的相关设置以便兼容 NDK (Native Development Kit)[^1]。具体改动涉及但不限于: - 设置交叉编译器路径; - 更改目标架构(armeabi-v7a, arm64-v8a 等); - 添加必要的宏定义用于区分不同平台特性; ```cmake if(ANDROID) set(CMAKE_SYSTEM_NAME Android) set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) # or other ABI as needed endif() ``` #### 使用 CMake 和 Ninja 进行实际编译流程 借助命令行工具调用 cmake 命令指定合适的参数启动构建任务。推荐使用 ninja 作为后台引擎加快处理速度。 ```bash mkdir build && cd build cmake .. -G"Ninja" \ -DCMAKE_TOOLCHAIN_FILE=$NDK_PATH/build/cmake/android.toolchain.cmake \ -DANDROID_PLATFORM=android-21 \ -DANDROID_STL=c++_shared \ .. ninja ``` 以上指令假设读者已经熟悉基本 shell 操作并且具备一定 Linux/Unix 下编程习惯。此外还需确认 `$NDK_PATH` 变量指向正确的本地 NDK 安装位置。 #### 解决可能出现的问题 如果遇到链接错误如 error LNK1181,则应仔细检查是否遗漏了某些必需的支持库或是路径设定有误。有时也需要更新至较新的 CMake 版本来规避潜在 bug 影响。 #### 测试与部署应用 成功完成后可利用 ADB 工具将生成的应用包推送至模拟器或真实硬件上运行调试。期间建议保持良好的日志记录意识方便定位问题所在。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值