在 OS X 上编译 OpenGL+OpenCL 代码时出错
Errors while compiling an OpenGL+OpenCL code on OS X
我正在尝试在我的 Mac 上编译 OpenGL+OpenCL 代码,经过大量努力设法安装依赖项并了解如何 link 它们(GLUI、GLUT、OpenCL , ETC)。
大部分错误已删除,但仍然存在 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 );
^
我尝试了所有我知道的编译器标志,但无法编译。该代码在朋友机器上的 Windows 上运行良好,但在我的 Mac OS X 上不起作用。我怀疑错误是因为错误中列出的 3 个函数是 windows 具体。由于我是 OpenGL 编程的新手,我不太了解 OS X 等效函数或者我的 Mac 需要哪些库才能使这些 windows 特定函数工作。
我添加了C++代码here以供参考:
这是我用于初始化 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
我正在尝试在我的 Mac 上编译 OpenGL+OpenCL 代码,经过大量努力设法安装依赖项并了解如何 link 它们(GLUI、GLUT、OpenCL , ETC)。
大部分错误已删除,但仍然存在 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 );
^
我尝试了所有我知道的编译器标志,但无法编译。该代码在朋友机器上的 Windows 上运行良好,但在我的 Mac OS X 上不起作用。我怀疑错误是因为错误中列出的 3 个函数是 windows 具体。由于我是 OpenGL 编程的新手,我不太了解 OS X 等效函数或者我的 Mac 需要哪些库才能使这些 windows 特定函数工作。
我添加了C++代码here以供参考:
这是我用于初始化 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