c++visual-studioeigenproject-settingsheader-only

Why can't I use C++ Eigen (header only lib) in two console apps within the same MS VS solution?


I made a Microsoft visual solution with two console app projects. I can use the Eigen library in one project by simply declaring it in the properties like so:

$(ProjectDir)Eigen\eigen3;

I can use library structures like "Eigen::Vector3d" etc no problem. Now when I try to copy the header-only lib into the second project folder and try to set the same property for the second one, and use the the structure I get compile errors.

Then when I don't copy the Eigen folder into the second one and simply try to refer from the second the folder in the first I get another set of compile time errors.

$(SolutionDir)someproject1\Eigen\eigen3;

Errors in second case is like so:

c:\users\alam syed\documents\someproject2.h(11): error C2653: 'Eigen': is not a class or namespace name

c:\users\alam syed\documents\someproject2.h(11): error C2065: 'Vector3f': undeclared identifier

c:\users\alam syed\documents\someproject2.h(11): error C2923: 'std::vector': 'Vector3f' is not a valid template type argument for parameter '_Ty'

c:\users\alam syed\documents\someproject2.h(11): error C2903: 'allocator': symbol is neither a class template nor a function template

c:\users\alam syed\documents\someproject2.h(11): error C3203: 'allocator': unspecialized class template can't be used as a template argument for template parameter '_Alloc', expected a real type

Why is it not ok to have two projects in the same solution trying to independently have their own libs in thier project folders ? Further why can't I refer Eigen folder from one to the first one ? Finally how can we bypass this quirk/by-design issue ?


Solution

  • I just tested this and it is possible in one solution.

    This even works if you don't rename the eigen folders.

    I can only think of two reasons why you would want to do this instead of using a common directory approach: