Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用CGL编译MacOS应用程序 我在C++上开发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; }_C++_Macos_Opengl_Cmake - Fatal编程技术网

用CGL编译MacOS应用程序 我在C++上开发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; }

用CGL编译MacOS应用程序 我在C++上开发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; },c++,macos,opengl,cmake,C++,Macos,Opengl,Cmake,我还使用Cmake生成XCode解决方案。 不幸的是,由于缺少必需的库,构建失败。我在cmake中尝试以下语句: set(CMAKE\u CXX\u FLAGS“${CMAKE\u CXX\u FLAGS}-framework CGL-framework OpenGL”) 和set(CMAKE_CXX_FLAGS“${CMAKE_CXX_FLAGS}-lCGL-lOpenGL”)没有运气 更新:以下是编译错误: Undefined symbols for architecture x86_64:

我还使用Cmake生成XCode解决方案。 不幸的是,由于缺少必需的库,构建失败。我在cmake中尝试以下语句:
set(CMAKE\u CXX\u FLAGS“${CMAKE\u CXX\u 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)
架构x86_64的未定义符号: “_CGLChoosePixelFormat”,引用自: libVEngineRenderer.a(EglWrapper.o)中的EglWrapperMac::EglWrapperMac(EglSetup const&,std::_1::shared_ptr) “_CGLCreateContext”,引用自: libvenginerender.a(EglWrapper.o)中的EglWrapperMac::CreateContext() “CGLDestroyPixelFormat”,引用自: EglWrapperMac::~EglWrapperMac()位于libVEngineRenderer.a(EglWrapper.o)中 “可绘制”,引用自: libvenginerender.a(EglWrapper.o)中的EglWrapperMac::Present() “_CGLGetCurrentContext”,引用自: libvenginerender.a(EglWrapper.o)中的EglWrapperMac::GetCurrentContext() “_CGLReleaseContext”,引用自: libVEngineRenderer.a(EglWrapper.o)中的EglWrapperMac::DeleteContext(_CGLContextObject*)) “_CGLSetCurrentContext”,引用自: libVEngineRenderer.a(EglWrapper.o)中的EglWrapperMac::MakeCurrent(_CGLContextObject*))
我该怎么办呢?

谢谢你的帮助。我能够用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})

如何显示您得到的错误?OS X中没有CGL框架(CGL包含在OpenGL框架中,您只需要
#包含OpenGL/OpenGL.h
),并且您也不使用
-lXXX
链接框架。现在,根据Makefile的结构,您可能还有一个称为LD_FLAGS的属性用于单独的链接阶段,您还需要在其中包含
-framework OpenGL
。此指令同时执行这两项操作,包括框架的路径解析和链接器路径解析。