Compiling CUDA program with OpenGL

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

#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).

Thanks. If I understand correct, I can use only <cuda_gl_interop.h> instead of other.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.