Closed Reticulatas closed 1 year ago
I figured this out. I'm not sure why, but the build succeeds when I do:
#include <Magnum/Platform/Sdl2Application.h>
instead of
#include <Magnum/Magnum.h>
Hi!
It's not because of CMake, it's because most Magnum types are forward-declared unless you explicitly include the header the type is defined in. Which is the case of <Magnum/Magnum.h>
that contains mainly just forward declarations of essential types, and to get the definition of Vector3
you have to #include <Magnum/Math/Vector3.h>
. To make it easier for you, each API in the docs explicitly lists what header to include to get the full definition.
It worked with <Magnum/Platform/Sdl2Application.h>
only because that header actually needs the full definition of the vector and so it includes <Magnum/Math/Vector3.h>
on its own.
I admit that this might feel unusual at first, as <SomeLibrary/SomeLibrary.h>
usually pulls in all types defined by given library. (For example Bullet, Eigen or Unreal does exactly that.) The reason for Magnum having just forward declarations in those headers is to optimize compilation times, see this part of the documentation for more information.
Hope this helps! :)
Thanks for the explanation, makes sense upon reading that doc!
Maybe a footnote in the example docs about includes linking to that page would be good?
This might be a misunderstanding of CMake on my part. Compiling a simple project is giving me
After following the setup guide, I added a new file to the bootstrap:
Here is my CMakeLists:
Building using VS0222 after running
cmake -DCMAKE_BUILD_TYPE=Debug ..
I can see the magnum lib being included in VS and there are no other errors- What is happening here? Tried Clean/Rebuild, remake CMake.