Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Help with Link error

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    736

    Help with Link error

    Hi all,
    I get a link error with this subrountine
    Code :
    vec4 aoit_UnpackColour(uint p_Colour)
    {    
      vec4 colour;
      const float norm = 1.0f / 255.0f;
      colour.x = float(p_Colour & 0xFF) * norm;
      colour.y = ((p_Colour >> 8) & 0xFF) * norm;
      colour.z = ((p_Colour >> 16) & 0xFF) * norm;
      colour.w = ((p_Colour >> 24) & 0xFF) * norm;
     
      return colour;    
    }

    but I get no link error when I include more code ( note I have not removed the code using the bit operation but I assume the compile is removing them because if I remove any assignment operator like colour.y = ... I get the link error again)

    Code :
    vec4 aoit_UnpackColour(uint p_Colour)
    {    
      vec4 colour;
      const float norm = 1.0f / 255.0f;
      colour.x = float(p_Colour & 0xFF) * norm;
      colour.y = ((p_Colour >> 8) & 0xFF) * norm;
      colour.z = ((p_Colour >> 16) & 0xFF) * norm;
      colour.w = ((p_Colour >> 24) & 0xFF) * norm;
      // 
      //  link fails with shift operator, so am using divide instead
      float a = floor(p_Colour / (256 * 256 * 256));   
      colour.w = a * norm;
     
      float b = floor( (p_Colour - a * 256 * 256 * 256) / (256 * 256));
      colour.z = b * norm;
     
      float g = floor( (p_Colour - a * 256 * 256 * 256 - b * 256 * 256) / (256));
      colour.y = g * norm;
     
      return colour;    
    }

    I am compiling in a nVidia geForce 580.

    As an aside the pack rountine is fine
    Code :
    uint aoit_PackColour(vec4 p_Colour)
    {
      uint colour;
      colour = uint(p_Colour.x * 255.0f) & 0xFF;              // r
      colour |= (uint(p_Colour.y * 255.0f) & 0xFF) << 8;      // g
      colour |= (uint(p_Colour.z * 255.0f) & 0xFF) << 16;     // b
      colour |= (uint(p_Colour.z * 255.0f) & 0xFF) << 24;     // a
     
      return colour;
    }

    Thanks

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    906

    Re: Help with Link error

    Care to share WHICH linker error you get?

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    736

    Re: Help with Link error

    Sure GL_INVALID_OPERATION. Not a lot of help

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    906

    Re: Help with Link error

    That is not a linker error. That's an OpenGL error. Retrieve the program info log to get info on program compilation and linkage and post it here. http://www.opengl.org/sdk/docs/man4/...ramInfoLog.xml

  5. #5

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    906

    Re: Help with Link error

    True, but if I'm not mistaken it also doesn't say anything about the compilation process - at least according to the API reference:

    GL_INVALID_OPERATION is generated if program is not a program object.

    GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.

    It could very well be an error set by some earlier command.

    tonyo_au: Please check if any of the above conditions are true in your case. If yes, correct your mistake and try again. If not, please call glGetError() immediately before glLinkProgram() and immediately after and see if the error persists. This way you can be sure that glLinkProgram() fails. If not, the error is generated by some other command before glLinkProgram().

    Edit: After you've done the above steps and the program still fails to execute properly, please get back with the program log as suggested previously.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    736

    Re: Help with Link error

    Thanks for the input guys,

    The link if failing, but you are right the INVALID_OPERATION is not coming from that - it is coming from the glGetShaderInfoLog! I wasn't catching until the next glGetError.

    The log info is "!!!!!!!!..."

    Code :
      CHECKOPENGL_WORRY;
      glLinkProgram( c_ProgramID );
      CHECKOPENGL_WORRY;
      glGetProgramiv( c_ProgramID, GL_LINK_STATUS, &amp;linked);
      CHECKOPENGL_WORRY;
      if (!linked)
      {
        int l, l1; 
        glGetProgramiv( c_ProgramID, GL_INFO_LOG_LENGTH, &amp;l);
        CHECKOPENGL_WORRY;
        GLchar* compilerSpew = new GLchar[l+1];
        glGetShaderInfoLog(c_ProgramID, l, &amp;l1, compilerSpew);
        CHECKOPENGL_WORRY; // *********************** this detects error
        OutputDebugStringA(compilerSpew);
        Util_Warning(_T("we failed to link program"));
        delete [] compilerSpew;
        return ( c_IsLinked = false );
       }

    I have narrowed the shader problem to the ">>" shift operator. If I remove that, the shader compiles and links with no problem.

    I am going to shift the code to an ATI machine to see what happens on it.

    Again, thanks for your help

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    736

    Re: Help with Link error

    I haven't solved this problem yet, but found these 2 functions to replace the code

    packUnorm4x6 and unpackUnorm4x8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •