1

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 ?

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48
Syed Alam Abbas
  • 521
  • 6
  • 21
  • Is `$(SolutionDir)someproject1` equal to `$(ProjectDir)`? (not sure how to test that) – NathanOliver Sep 18 '18 at 20:23
  • 1
    Have you #included everything you need to #include? – Paul Sanders Sep 18 '18 at 20:27
  • @NathanOliver no $(SolutionDir)someproject1 macro shows the right directory. – Syed Alam Abbas Sep 18 '18 at 20:43
  • @PaulSanders I cant include any header from Eigen without getting the compile errors. In the project settings just the root directory of Eigen allows you to have everything, then you only include what you use. – Syed Alam Abbas Sep 18 '18 at 20:43
  • Create a "common" directory in `$(SolutionDir)`, copy the lib headers there and either include the headers per "../common/..." or add it to the include path of all your projects. – rpress Sep 18 '18 at 22:12
  • @rpress I don't wish to have such common directories, my goal is to create two fully independent projects with self-contained libs, perhaps that is not achievable in the same solution? – Syed Alam Abbas Sep 18 '18 at 22:57

1 Answers1

1

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

  • created empty solution
  • added two console projects
  • copied eigen headers from zip into each of the two projects
  • renamed them to eigen1 in the first project folder and eigen2 in the second project folder
  • created two .cpp files in each of the projects using tutorial code from eigen docs
  • set ($ProjectDir)eigen1 as "Additional Include Directories" in the first project and ($ProjectDir)eigen2 in the second project
  • checked the built debug binaries if they reference the correct eigen headers in the embedded debug info

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:

  • each of the projects uses a different version of the libs or you want to have the flexibility for this option later
  • you want to use customized versions of eigen (and/or other libs) applying your own patches
rpress
  • 462
  • 3
  • 6
  • Why you had to use this : used #include "Eigen/Dense" instead of #include ? Will it not compile ? Naming the root folders in each of the project as different, I don't have a problem with. But I was trying with the same name. Worse case for me would be to simply make two solutions with their each individual projects and not have a common solution. – Syed Alam Abbas Sep 19 '18 at 13:32
  • Just checked, that step is unnecessary. Edited my answer. – rpress Sep 19 '18 at 14:00