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 2 of 2

Thread: Problem including glm extensions

  1. #1
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    3

    [SOLVED] Problem including glm extensions

    I've been trying to use some GLM extensions (GTX) in my source code without success. They fail when gcc tries to link them.
    I created a test code that does nothing. I just wanted to test if I'd be able to include extensions.

    The code is the following:
    Code :
    #include <glm/glm.hpp>
    #include <glm/gtx/closest_point.hpp>
     
    int foo()
    {
            glm::vec3 p1(0,0,0) , p2(0,1,0), p3(0,0,1);
    	glm::closestPointOnLine(p1,p2,p3);
     
            return 0;
    }
     
    int main() {
     
    	return foo();
     
    }

    I'm able to generate the object file with gcc, but when I try to generate the executable the following error is returned:
    Code :
    teste.cpp:(.text+0xa3): undefined reference to `glm::detail::tvec3<float> glm::gtx::closest_point::closestPointOnLine<float>(glm::detail::tvec3<float> const&, glm::detail::tvec3<float> const&, glm::detail::tvec3<float> const&)'

    GLM is supposed to be header-only, so it can't be a missing library problem when compiling.


    I tried to take a look at "/usr/include/glm/gtx/closest_point.hpp", and I noticed that the method is actually implemented in "/usr/include/glm/gtx/closest_point.inl". The HPP file includes the INL, however there was something there that did not seem to make sense to me.

    Both files contain the following definition on top of them:
    Code :
    #ifndef glm_gtx_closest_point
    #define glm_gtx_closest_point

    It does not seem that the implementation will ever be actually included.
    Last edited by marcojrfurtado; 11-09-2012 at 11:28 PM. Reason: Problem solved

  2. #2
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    3
    So, it seems that closest_point is the only extension I tried that does not work.
    I'm including it in my code the following way.

    Code :
    #include <glm/gtx/closest_point.hpp>
    #undef glm_gtx_closest_point
    #include <glm/gtx/closest_point.inl>

    Now it works, even though this is the wrong way to fix it. I downloaded libglm-dev from ubuntu repositories, version 0.9.2.7-1.
    I noticed this is no longer a problem in newer versions, as the include was fixed.
    I hope they update the repositories. I hate using stupid hacks to make things work correctly.

Posting Permissions

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