I’ve added the “#version 420 core” preamble to each shader.
I know I shouldn’t use the glProgramParameteriEXT function to define GL_GEOMETRY_INPUT_TYPE_EXT, GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_GEOMETRY_VERTICES_OUT_EXT,
because these parameters are specified in the geometry shader (which is core in OpenGL 4.2).

EDIT:
My mistake was incorrect usage of glVertexAttribPointer (wrong value of the the last parameter).
Thanks for all the answers and sorry for your wasted time!

One Response to “How to enable geometry shader in OpenGL 4.2?”

Geometry shader is only available in GLSL version 1.5 and later, and you need to specify that explicitly in the geometry shader source. I guess it’s #version 400 in your case. Here is the list of GLSL verseions.