[英]Errors while compiling an OpenGL+OpenCL code on OS X
I am trying to compile an OpenGL+OpenCL code on my Mac and after a lot of efforts managed to get the dependencies installed and understood how to link them (GLUI, GLUT, OpenCL, etc). 我正在尝试在Mac上编译OpenGL + OpenCL代码,经过大量努力,设法安装了依赖项并了解如何链接它们(GLUI,GLUT,OpenCL等)。
Most of the errors are removed but there are 3 errors that still persist as shown below: 大部分错误已被删除,但仍然存在3个错误,如下所示:
pranjal:~/parallel-prog$ g++-4.9 mittalp.cpp -fopenmp -framework OpenCL -framework OpenGL -framework GLUI -framework GLUT -w
mittalp.cpp: In function 'void InitCL()':
mittalp.cpp:465:69: error: 'wglGetCurrentContext' was not declared in this scope
CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext( ),
^
mittalp.cpp:466:62: error: 'wglGetCurrentDC' was not declared in this scope
CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC( ),
^
mittalp.cpp: In function 'void InitGlui()':
mittalp.cpp:619:37: error: 'FALSE' was not declared in this scope
Glui->add_column_to_panel( panel, FALSE );
^
I tried all compiler flags I knew and wasn't able to compile. 我尝试了所有我知道并且无法编译的编译器标志。 The code works well on Windows on a friend's machine but it does not work on my Mac OS X. I am suspecting the errors are because the 3 functions listed in the errors are windows specific.
该代码在朋友的机器上的Windows上运行良好,但在我的Mac OS X上却无法运行。我怀疑这些错误是因为错误中列出的3个功能是Windows特有的。 Since I am a new to OpenGL programming, I do not have much knowledge of OS X equivalent functions or what libraries are needed on my Mac to make these windows specific functions work.
由于我是OpenGL编程的新手,因此我对OS X等效功能或Mac上需要哪些库才能使这些特定于Windows的功能正常工作的知识不多。
I have added the C++ code here for reference: 我在这里添加了C ++代码以供参考:
Here's the code that I use for initialising the OpenCL context properties to enable OpenGL interoperability on Windows, OS X and Linux: 这是我用于初始化OpenCL上下文属性以在Windows,OS X和Linux上启用OpenGL互操作性的代码:
#if defined(_WIN32)
// Windows
cl_context_properties properties[] = {
CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
CL_CONTEXT_PLATFORM, (cl_context_properties)platform,
0
};
#elif defined(__APPLE__)
// OS X
CGLContextObj kCGLContext = CGLGetCurrentContext();
CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext);
cl_context_properties properties[] = {
CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
(cl_context_properties) kCGLShareGroup,
0
};
#else
// Linux
cl_context_properties properties[] = {
CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
CL_CONTEXT_PLATFORM, (cl_context_properties)platform,
0
};
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.