gpt4 book ai didi

c++ - 使用带有 cmake 的 OpenGL ES 2.0 生成 iOS 静态库

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:38:06 28 4
gpt4 key购买 nike

我正在为多平台渲染器(目前至少是 iOS/Mac)编写构建工具链。该项目有一个核心库(每个平台目标都将使用的那个),应该将其编译为静态库(.a)以便在其他平台相关项目(如 xcode 项目或 eclipse 中)中使用用于进一步的android开发)。

此静态库依赖于 OpenGL ES 2.0 (iOS) 或 OpenGL for Mac。所以我有以下文件以包含正确的标题:

#ifdef PLATFORM_IOS
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#endif

#ifdef PLATFORM_OSX
#include <OpenGL/gl.h>
#include <GLFW/glfw3.h>
#endif

事实是它在 Mac 平台上工作得很好,cmake 正确地找到了 OpenGL 头文件,但是对于 iOS,它没有找到 OpenGLES;即使使用我编写的 FindOpenGLES.cmake 模块,我也找不到这些 header ,这似乎合乎逻辑,因为我什至没有在/usr/include 中找到它们。

最佳答案

您可能需要设置 CMAKE_SYSTEM_FRAMEWORK_PATH ,以下是我iOS自带的工具链文件

  set (IOS_SDK_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk")

# Set the sysroot default to the most recent SDK
set (CMAKE_OSX_SYSROOT ${IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")

# set the architecture for iOS - this env var sets armv6,armv7 and appears to be XCode's standard. The other found is ARCHS_UNIVERSAL_IPHONE_OS but that is armv7 only
set (CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE string "Build architecture for iOS")

# set up the default search directories for frameworks
set (CMAKE_SYSTEM_FRAMEWORK_PATH ${IOS_SDK_ROOT}/Developer/Library/Frameworks)

关于c++ - 使用带有 cmake 的 OpenGL ES 2.0 生成 iOS 静态库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25984767/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com