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:
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?
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