Results 1 to 2 of 2

Thread: Problem including glm extensions

  1. #1

    [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);
            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.

  2. #2
    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
    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.

Similar Threads

  1. Problem Including Headers in Kernels
    By sean.settle in forum OpenCL
    Replies: 1
    Last Post: 09-14-2011, 12:21 PM
  2. The problem of including OpenMAXAL_IID.h
    By JaeUnHong in forum OpenMAX
    Replies: 1
    Last Post: 05-29-2008, 08:40 AM
  3. Problem with including the glut.h
    By Jackyboy in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 03-16-2006, 07:19 PM
  4. Extensions problem...
    By dabeav in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 01-19-2004, 02:09 AM
  5. Problem with GL Extensions
    By in forum OpenGL: User Software
    Replies: 30
    Last Post: 08-14-2002, 08:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean