Getting "GL_INVALID_ENUM" when calling glEnable(GL_TEXTURE_2D)

It sounds as if you have an OpenGL 3+ core profile context, where GL_TEXTURE_2D is indeed not a valid argument to glEnable() (it’s only meaningful for the fixed-function pipeline, and OpenGL 3+ core profile doesn’t support the fixed-function pipeline).