PDA

View Full Version : Compiling CUDA program with OpenGL



amalik
10-16-2017, 06:38 PM
Hi all,

I am trying to compile a CUDA program which uses OpenGL APIs. When I compiled it using the following command:

nvcc -O2 -arch=sm_50 -lGL -lGLX -o out julia_cpu.cu

I got the following error messages:

/usr/include/GL/glext.h(111): error: identifier "GLenum" is undefined

/usr/include/GL/glext.h(111): error: identifier "GLuint" is undefined

/usr/include/GL/glext.h(111): error: identifier "GLuint" is undefined

/usr/include/GL/glext.h(111): error: identifier "GLsizei" is undefined

/usr/include/GL/glext.h(111): error: identifier "GLenum" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLenum" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLint" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLint" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLsizei" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLsizei" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLsizei" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLint" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLenum" is undefined

/usr/include/GL/glext.h(112): error: identifier "GLenum" is undefined

/usr/include/GL/glext.h(113): error: identifier "GLenum" is undefined

/usr/include/GL/glext.h(113): error: identifier "GLint" is undefined

/usr/include/GL/glext.h(113): error: identifier "GLint" is undefined


How can I remove these errors?

Thanks,

malik

Dark Photon
10-17-2017, 07:05 AM
#include <GL/glext.h> requires that <GL/gl.h> be included first, as it defines the typedefs for the symbols that are undefined above.

Alternatively, you could try including <cuda_gl_interop.h> first if you want. I think it pulls in <GL/gl.h> for you (but double-check that).

amalik
10-18-2017, 11:41 AM
Thanks. If I understand correct, I can use only <cuda_gl_interop.h> instead of other.