4

Recently I am using Eigen library for a project. I’m curious why there’s no binary file to link, but only a header. I don’t really understand how Eigen works behind the scene to make this possible.

jackxujh
  • 983
  • 10
  • 31
  • 3
    Read the source code - it's all in the headers – UnholySheep Dec 01 '18 at 19:13
  • 2
    @UnholySheep Right, I just found out. But why is it still necessary to link Eigen library when working with CMake? – jackxujh Dec 01 '18 at 19:15
  • 2
    CMake linking is not the exact same as linking a precompiled library. Eigen provides a "library target" for CMake which you are linking, but this does not mean you are linking to a binary – UnholySheep Dec 01 '18 at 19:19
  • @UnholySheep Really appreciate your explanation! I also found a related thread here: https://stackoverflow.com/a/51887180/7299097 . I am now reading to learn more about the mechanism. – jackxujh Dec 01 '18 at 19:25
  • Not sure what your question is actually about. Header-only libraries generally "work" by having every function `inline` (explicitly or implicitly). If this is about how this affects building with CMake, state that in your question more clearly (ideally showing a problem which you have). – chtz Dec 03 '18 at 12:23

0 Answers0