0

I'm currently working with OpenGL use glm library, I see each header file (*.hpp) had it own implementation file (*.inl) but how can it auto-compile (or linking) glm each time we compile project? For example:

#include <glm/glm.hpp>
// We actualy dont included any *.inl files
// And in glm.hpp (or any *.hpp files) are not included too!

but when compile, it had no error!

Bình Nguyên
  • 2,252
  • 6
  • 32
  • 47
  • Actualy, I see some `#include "*.inl"` declation in some header files now, so, if we include one header on more `*.cpp` file in own project, are those functions duplicated? – Bình Nguyên Feb 14 '13 at 09:32

1 Answers1

6

From the glm/glm/core/dummy.cpp:

/// GLM is a header only library. There is nothing to compile. 
/// dummy.cpp exist only a wordaround for CMake file.

So you have to include the headers in your project and that's it (similar to boost) . You are correct about the .inl files, they are included by headers. Headers have guards, so there will be no duplication.

Community
  • 1
  • 1
Kimi
  • 13,621
  • 9
  • 55
  • 84
  • Not all the BOOST is header only libs ;) But +1 for the answer :) – Michael IV Feb 14 '13 at 12:39
  • for example, I have two files: `a.cpp` and `b.cpp`. In these files, I included: `glm/glm.hpp`, `glm/gtc/matrix_transform.hpp`, so, How headers guards can prevent two functions from dupplication (I mean one function - for example is `gtm::perspective` is have two implements in `a.obj` and `b.obj`)? – Bình Nguyên Feb 14 '13 at 13:51
  • In short, don't worry about it. glm::perspective is a function template, and header has a template, not a function definition. Long answer is outside the scope of the original question, but if you look up *Template Instantiation* you might get on track. – Kimi Feb 14 '13 at 15:25