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: How do I compile a .c file that uses glm.h? ["undefined references"]

  1. #1
    Newbie Newbie
    Join Date
    May 2013
    Posts
    1

    How do I compile a .c file that uses glm.h? ["undefined references"]

    Hello guys,

    I'm writing a simple code (using gedit on Ubuntu) in C to import a 3d model (.obj).

    In my code I'm using the library "glm.h" and I'm using the following commands:

    GLMmodel* f16;
    f16 = (GLMmodel*)malloc(sizeof(GLMmodel));
    f16 = glmReadOBJ("./objs/f16.obj");

    in order to compile, I'm using the following line:
    gcc -Wall test.c -o test -lglut

    but terminal prints the following errors:

    "undefined reference to glmDraw
    undefined reference to glmReadObj"

    What can I do to compile my code correctly?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659
    glm.h is the header file of the library. somewhere in your system, probably in /usr/lib, there has to be something like libglm.so or similar, which is the library itself.
    in general, header files like glm.h are for compilation only. if you compile without linking (gcc -c test.c), there should be no error. if you want to create an executable,
    you have to list the library dependencies. you have already added -lglut to link to libglut.so, so you have probably to add -lglm (assuming that the lib glm is named
    libglm.so). so, in total, try: gcc -Wall test.c -o test -lglut -lglm

Posting Permissions

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