我正在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中尝试以下语句:
set(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)
我该如何处理?
答案 0 :(得分:2)
感谢您的帮助。我能够通过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})