gpt4 book ai didi

c++ - 使用 CGL 编译 MacOS 应用程序

转载 作者:行者123 更新时间:2023-11-30 04:13:12 27 4
gpt4 key购买 nike

我正在 Mac 上开发 C++ 应用程序并使用 CGL 来初始化 OpenGL:

EGL_CONTEXT EglWrapperMac::CreateContext() {
EGL_CONTEXT context;
if (kCGLNoError != CGLCreateContext(m_display, NULL, &context)) {
throw EXT_EXCEPTION(EGL_WRAPPER_ERROR_CREATE_CTX);
}
return context;
}

我还使用 Cmake 生成 XCode 解决方案。不幸的是,由于缺少所需的库,构建失败。我在 cmake 中尝试以下语句: 设置(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework CGL -framework OpenGL")set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lCGL -lOpenGL") 没有运气。

更新:编译错误如下:

Undefined symbols for architecture x86_64:

"_CGLChoosePixelFormat", referenced from:
EglWrapperMac::EglWrapperMac(EglSetup const&, std::__1::shared_ptr<IEngineWindow>) in libVEngineRenderer.a(EglWrapper.o)
"_CGLCreateContext", referenced from:
EglWrapperMac::CreateContext() in libVEngineRenderer.a(EglWrapper.o)
"_CGLDestroyPixelFormat", referenced from:
EglWrapperMac::~EglWrapperMac() in libVEngineRenderer.a(EglWrapper.o)
"_CGLFlushDrawable", referenced from:
EglWrapperMac::Present() in libVEngineRenderer.a(EglWrapper.o)
"_CGLGetCurrentContext", referenced from:
EglWrapperMac::GetCurrentContext() in libVEngineRenderer.a(EglWrapper.o)
"_CGLReleaseContext", referenced from:
EglWrapperMac::DeleteContext(_CGLContextObject*) in libVEngineRenderer.a(EglWrapper.o)
"_CGLSetCurrentContext", referenced from:
EglWrapperMac::MakeCurrent(_CGLContextObject*) in libVEngineRenderer.a(EglWrapper.o)

我该如何处理?

最佳答案

感谢您的帮助。我能够在 cmake 中使用以下代码解决问题:

include_directories ( /System/Library/Frameworks )
find_library(OpenGL_LIBRARY OpenGL )
set(EXTRA_LIBS ${OpenGL_LIBRARY})

//add_library (VEngineRenderer STATIC ${RENDER_FILES})

target_link_libraries(VEngineRenderer ${EXTRA_LIBS})

关于c++ - 使用 CGL 编译 MacOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19480099/

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