title: OpenGL shaders don't link with shader program
body: <p>I am trying to add shaders with GLFW/GLEW.</p>
  
  <p>I am getting an error that the shaders are loaded but they don't have valid object code.</p>
  
  <p>This is the code I have for loading the shaders:</p>
  
  <pre><code>class SHADER {
  public:
  
  void LoadShaders(const char *vertexFile, const char *fragmentFile);
  
  char *vertexShader;
  char *fragmentShader;
  
  private:
  
  int Load(const char *filename, char*&amp;shaderSource);
  fstream file;
  };
  
  int SHADER::Load(const char *filename, char *&amp;shaderSource) {
  file.open(filename, ios::in);
  if(file.is_open()) {
      file.tellg();
      file.seekg(0,ios::end);
      unsigned long len = file.tellg();
      file.seekg(ios::beg);
  
      if(len == 0 ) {
          return -2;
      } else {
          shaderSource = new char[len + 1];
          file.read(shaderSource,len);
          file.close();
          printf("%s\n",shaderSource);
      }
  } else {
      return -1;
  }
  return 0;
  }
  
  void SHADER::LoadShaders(const char *vertexFile, const char *fragmentFile) {
  int resultVertex = this-&gt;Load(vertexFile, vertexShader);
  int resultFragment = this-&gt;Load(fragmentFile, fragmentShader);
  if(resultVertex ==0 &amp;&amp; resultFragment ==0) {
      printf("Shaders loaded succesfully.\n");
  }
  if(resultVertex == -2) {
      printf("VertexShader is empty!\n");
  }
  if(resultFragment == -2) {
      printf("FragmentShader is empty!\n");
  }
  if(resultVertex == -1) {
      printf("Unable to load VertexShader!\n");
  }
  if(resultFragment == -1) {
      printf("Unable to load FragmentShader!\n");
  }
  }
  </code></pre>
  
  <p>This is the code for initializing the shaders:</p>
  
  <pre><code>SHADER Shaders;
  GLhandleARB vertexShader, fragmentShader, shaderProgram;
  
  Shaders.LoadShaders("vertexShader.vert","fragmentShader.frag");
  
  const char* vertTemp = Shaders.vertexShader;
  vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
  glShaderSourceARB(vertexShader, 1, &amp;vertTemp, NULL);
  glCompileShaderARB(vertexShader);
  traceShaderInfoLog(vertexShader);
  
  const char* fragTemp = Shaders.fragmentShader;
  fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
  glShaderSourceARB(fragmentShader, 1, &amp;fragTemp, NULL);
  glCompileShaderARB(fragmentShader);
  traceShaderInfoLog(fragmentShader);
  
  delete[] Shaders.vertexShader;
  delete[] Shaders.fragmentShader;
  
  shaderProgram = glCreateProgramObjectARB();
  glAttachObjectARB(shaderProgram,vertexShader);
  glAttachObjectARB(shaderProgram,fragmentShader);
  glLinkProgramARB(shaderProgram);
  traceProgramInfoLog(shaderProgram);
  
  glUseProgramObjectARB(shaderProgram);
  </code></pre>
  
  <p>This is vertexShader.vert and fragmentShader.frag:</p>
  
  <pre><code>void main(){
  gl_Position = ftransform();
  }
  void main(){
  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
  }
  </code></pre>
  
  <p>And this is the error I get when I print the log, I get this really weird symbol at the end of the scripts which is every time I compile again another symbol:</p>
  
  <pre><code>void main(){
      //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
      gl_Position = ftransform();
  }┘
  void main(){
      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
  }♣
  Shaders loaded succesfully.
  Vertex shader was successfully compiled to run on hardware.
  
  Fragment shader failed to compile with the following errors:
  ERROR: 0:3: error(#132) Syntax error: '&lt;' parse error
  ERROR: error(#273) 1 compilation errors.  No code generated
  
  Fragment shader(s) were not successfully compiled before glLinkProgram() was called.
  Link failed.
  </code></pre>