Tuesday, May 4, 2010

Devil lies in details

I've just spent an hour looking for an error not letting me compile some c++ + openGL code on Visual Studio. The problem occurred after adding GLM library code(glm.h) from glut's demo programs. After triple-checking my usage of the library, googling my error ("unresolved external symbol "), trying on different project I've finally found out the source of the problem. Pretty silly to be honest.

Everything compiled until I used a function from the library - it couldn't be resolved.

The problem was that the library was in C, while my code was C++. Even though the glm.h + glm.c compiled, trying to call a function defined in glm.h was not possible because the compiler tried to find it in glm.cpp.

Changing the name to glm.cpp and minor c->c++ changes fixed the problem.

If you're interested, you can find glut source and demo code here. The library for loading .OBJ model files is in progs\demos\smooth.

Another thing you might find interesting is this Pearl script converting OBJ files to arrays hard-coded in a header file. I haven't tried it out in practice because I use very big models.

No comments:

Post a Comment