robotology / osqp-eigen

Simple Eigen-C++ wrapper for OSQP library
https://robotology.github.io/osqp-eigen/
BSD 3-Clause "New" or "Revised" License
396 stars 118 forks source link

Devel breaks idyntree::optimal_control #61

Closed S-Dafarra closed 4 years ago

S-Dafarra commented 4 years ago

The first error is the following

t searching for unused variables given on the command line.
loading initial cache file /home/sdafarra/Software/robotology-superbuild/build/robotology/iDynTree/CMakeFiles/YCMTmp/iDynTree-cache-Release.cmake
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "3.2.92") 
-- Found YARP: /home/sdafarra/Software/robotology-superbuild/build/install/lib/cmake/YARP (found version "3.3.2+43-20200411.3+gita33cf54b1")
-- Found YARP: /home/sdafarra/Software/robotology-superbuild/build/install/lib/cmake/YARP (found version "3.3.2+43-20200411.3+gita33cf54b1")
-- Using iCub from install
-- Found YARP: /home/sdafarra/Software/robotology-superbuild/build/install/lib/cmake/YARP (found version "3.3.2+43-20200411.3+gita33cf54b1")
CMake Error at /usr/share/cmake-3.16/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  By not providing "FindEigen.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Eigen", but
  CMake did not find one.

  Could not find a package configuration file provided by "Eigen" with any of
  the following names:

    EigenConfig.cmake
    eigen-config.cmake

  Add the installation prefix of "Eigen" to CMAKE_PREFIX_PATH or set
  "Eigen_DIR" to a directory containing one of the above files.  If "Eigen"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  /home/sdafarra/Software/robotology-superbuild/build/install/lib/cmake/OsqpEigen/OsqpEigenConfig.cmake:23 (find_dependency)
  cmake/iDynTreeDependencies.cmake:51 (find_package)
  cmake/iDynTreeDependencies.cmake:91 (idyntree_handle_dependency)
  CMakeLists.txt:43 (include)

-- Configuring incomplete, errors occurred!
See also "/home/sdafarra/Software/robotology-superbuild/build/robotology/iDynTree/CMakeFiles/CMakeOutput.log".
make[2]: *** [CMakeFiles/iDynTree.dir/build.make:104: robotology/iDynTree/CMakeFiles/YCMStamp/iDynTree-configure] Error 1
make[1]: *** [CMakeFiles/Makefile2:1108: CMakeFiles/iDynTree.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

which can be easily solved by changing https://github.com/robotology/osqp-eigen/blob/devel/CMakeLists.txt#L110 to

list(APPEND OSQP_EIGEN_EXPORTED_DEPENDENCIES osqp Eigen3)

but if I try to compile again I get the following error

[ 25%] Performing configure step for 'iDynTree'
Not searching for unused variables given on the command line.
loading initial cache file /home/sdafarra/Software/robotology-superbuild/build/robotology/iDynTree/CMakeFiles/YCMTmp/iDynTree-cache-Release.cmake
-- Found YARP: /home/sdafarra/Software/robotology-superbuild/build/install/lib/cmake/YARP (found version "3.3.2+43-20200411.3+gita33cf54b1")
-- Found YARP: /home/sdafarra/Software/robotology-superbuild/build/install/lib/cmake/YARP (found version "3.3.2+43-20200411.3+gita33cf54b1")
-- Using iCub from install
-- Found YARP: /home/sdafarra/Software/robotology-superbuild/build/install/lib/cmake/YARP (found version "3.3.2+43-20200411.3+gita33cf54b1")
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0") 
CMake Warning (dev) at /usr/share/cmake-3.16/Modules/FindOpenGL.cmake:275 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  src/visualization/CMakeLists.txt:63 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Configuring done
CMake Error at src/optimalcontrol/CMakeLists.txt:107 (add_library):
  Target "idyntree-optimalcontrol" links to target "Eigen3::Eigen" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?

CMake Error at src/optimalcontrol/CMakeLists.txt:107 (add_library):
  Target "idyntree-optimalcontrol" links to target "Eigen3::Eigen" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
make[2]: *** [CMakeFiles/iDynTree.dir/build.make:104: robotology/iDynTree/CMakeFiles/YCMStamp/iDynTree-configure] Error 1
make[1]: *** [CMakeFiles/Makefile2:1108: CMakeFiles/iDynTree.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

It seems weird since Eigen3::Eigen should be added when finding Eigen3.

@GiulioRomualdi @traversaro

traversaro commented 4 years ago

I suggest to do list(APPEND OSQP_EIGEN_EXPORTED_DEPENDENCIES osqp "Eigen3 CONFIG"), as otherwise if you do a find_dependency(Eigen3 REQUIRED) in an arbitrary project you never know if this will use a local FindEigen3.cmake or the Eigen3Config.cmake file (that I guess it is what is happening).

traversaro commented 4 years ago

Indeed, the local FindEigen3.cmake of iDynTree does not define a target Eigen3::Eigen , and that is what is happening. While we could fix the iDynTree FindEigen3.cmake file, this would just hide the problem that could occur also elsewhere.

S-Dafarra commented 4 years ago

I suggest to do list(APPEND OSQP_EIGEN_EXPORTED_DEPENDENCIES osqp "Eigen3 CONFIG"), as otherwise if you do a find_dependency(Eigen3 REQUIRED) in an arbitrary project you never know if this will use a local FindEigen3.cmake or the Eigen3Config.cmake file (that I guess it is what is happening).

Awesome! That fixes the issue. I'll open a PR for this.

this would just hide the problem that could occur also elsewhere.

It is already happening now whole-body-estimators fails with

[ 45%] Building CXX object devices/baseEstimatorV1/CMakeFiles/baseEstimatorV1.dir/src/baseEstimatorV1.cpp.o
In file included from /home/sdafarra/Software/robotology-superbuild/robotology/whole-body-estimators/devices/baseEstimatorV1/include/baseEstimatorV1.h:21,
                 from /home/sdafarra/Software/robotology-superbuild/robotology/whole-body-estimators/devices/baseEstimatorV1/src/baseEstimatorV1.cpp:9:
/home/sdafarra/Software/robotology-superbuild/build/install/include/iDynTree/Core/EigenHelpers.h:14:10: fatal error: Eigen/Dense: No such file or directory
   14 | #include <Eigen/Dense>
      |          ^~~~~~~~~~~~~
compilation terminated.
make[5]: *** [devices/baseEstimatorV1/CMakeFiles/baseEstimatorV1.dir/build.make:63: devices/baseEstimatorV1/CMakeFiles/baseEstimatorV1.dir/src/baseEstimatorV1.cpp.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:515: devices/baseEstimatorV1/CMakeFiles/baseEstimatorV1.dir/all] Error 2
make[3]: *** [Makefile:130: all] Error 2
make[2]: *** [CMakeFiles/whole-body-estimators.dir/build.make:110: robotology/whole-body-estimators/CMakeFiles/YCMStamp/whole-body-estimators-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:426: CMakeFiles/whole-body-estimators.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

I guess that idyntree_optimal_control is the was the responsible of having Eigen available when linking ${iDynTree_LIBRARIES} (my bad :grin:).

S-Dafarra commented 4 years ago

And walking-controllers :sweat_smile:

[  7%] Building CXX object src/iDynTreeUtilities/CMakeFiles/iDynTreeUtilities.dir/src/Helper.cpp.o
In file included from /home/sdafarra/Software/robotology-superbuild/robotology/walking-controllers/src/iDynTreeUtilities/src/Helper.cpp:16:
/home/sdafarra/Software/robotology-superbuild/build/install/include/iDynTree/Core/EigenHelpers.h:14:10: fatal error: Eigen/Dense: No such file or directory
   14 | #include <Eigen/Dense>
      |          ^~~~~~~~~~~~~
compilation terminated.
make[5]: *** [src/iDynTreeUtilities/CMakeFiles/iDynTreeUtilities.dir/build.make:63: src/iDynTreeUtilities/CMakeFiles/iDynTreeUtilities.dir/src/Helper.cpp.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:1305: src/iDynTreeUtilities/CMakeFiles/iDynTreeUtilities.dir/all] Error 2
make[3]: *** [Makefile:141: all] Error 2
make[2]: *** [CMakeFiles/walking-controllers.dir/build.make:114: robotology/walking-controllers/CMakeFiles/YCMStamp/walking-controllers-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:1026: CMakeFiles/walking-controllers.dir/all] Error 2
make: *** [Makefile:95: all] Error 2
S-Dafarra commented 4 years ago

Related PRs:

GiulioRomualdi commented 4 years ago

Since #62 has been merged, I think we can close this issue

traversaro commented 4 years ago

Not sure about what is happening, but it is still failing on some jobs of the robotology-superbuild, see https://github.com/robotology/robotology-superbuild/pull/408/checks?check_run_id=677177776 .

GiulioRomualdi commented 4 years ago

Seems that it's failing only on Debian. Do you think that the Eigen3Config.cmake is not shipped with the Eigen installed in that distro?

traversaro commented 4 years ago

Seems that it's failing only on Debian. Do you think that the Eigen3Config.cmake is not shipped with the Eigen installed in that distro?

I saw that it was also failing on Ubuntu 20.04, but you don't see because as soon as one job fails it halts the other. However, Eigen3Config.cmake is shipped there: https://packages.debian.org/sid/all/libeigen3-dev/filelist . I wonder if there is some weird CMake problem that affects only a specific CMake version.

S-Dafarra commented 4 years ago

I saw that it was also failing on Ubuntu 20.04, but you don't see because as soon as one job fails it halts the other. However, Eigen3Config.cmake is shipped there: https://packages.debian.org/sid/all/libeigen3-dev/filelist . I wonder if there is some weird CMake problem that affects only a specific CMake version.

I have CMake 3.16.3 on Ubuntu 20.04. It compiles with the following setup

--------------------------------------------
BlockFactory/: master
3 months ago|Update FindMatlab.cmake file to the version in CMake 3.16.3
--------------------------------------------
funny-things/: master
3 months ago|Merge pull request #14 from robotology/fix/13
--------------------------------------------
GazeboYARPPlugins/: master
5 weeks ago|Merge pull request #479 from prashanthr05/fix/doc-basestate-plugin
--------------------------------------------
ICUB/: master
2 weeks ago|Merge pull request #656 from robotology/traversaro-patch-1
--------------------------------------------
icub-basic-demos/: master
3 months ago|depends on yarp-3.3.2
--------------------------------------------
ICUBcontrib/: master
3 months ago|depends on yarp-3.3.2
--------------------------------------------
icub-gazebo/: master
3 months ago|Merge pull request #73 from robotology/migrate-urdf-model
--------------------------------------------
icub-gazebo-wholebody/: master
9 months ago|Merge pull request #28 from robotology/devel
--------------------------------------------
icub-models/: master
9 weeks ago|Merge pull request #27 from S-Dafarra/feature/fixedModels
--------------------------------------------
iDynTree/: master
9 days ago|Bump version and release 1.0.6 (#690)
--------------------------------------------
OsqpEigen/: devel
17 hours ago|Merge pull request #62 from S-Dafarra/fix/eigenDependency
--------------------------------------------
robots-configuration/: master
10 weeks ago|Merge pull request #175 from lrapetti/fix-sole-calibration-iCubGenova02
--------------------------------------------
speech/: master
3 months ago|disable build of SpeechRecognizer by default
--------------------------------------------
UnicyclePlanner/: master
4 months ago|Merge pull request #32 from robotology/bumpVersion
--------------------------------------------
walking-controllers/: master
17 hours ago|Merge pull request #62 from S-Dafarra/fix/linkEigen
--------------------------------------------
walking-teleoperation/: master
11 months ago|Update README.md
--------------------------------------------
WBToolbox/: master
4 months ago|Merge branch 'devel'
--------------------------------------------
whole-body-controllers/: master
7 weeks ago|Update README.md
--------------------------------------------
whole-body-estimators/: master
13 hours ago|Merge pull request #68 from S-Dafarra/fix/findEigen3
--------------------------------------------
YARP/: yarp-3.3
5 weeks ago|Cleanup OS -> os
--------------------------------------------
yarp-matlab-bindings/: yarp-3.3
6 months ago|Merge pull request #43 from robotology/traversaro-patch-1
--------------------------------------------
YCM/: ycm-0.11
2 weeks ago|Merge pull request #334 from robotology/fix-octave-ycm-0-11
GiulioRomualdi commented 4 years ago

I tried to run a clean Docker image with the scripts in https://github.com/robotology/robotology-superbuild/tree/master/.ci and everything is working. Noticed I used osqp-eigen devel

traversaro commented 4 years ago

Indeed I was wrong, the only failure is just on Debian Sid: https://github.com/robotology/robotology-superbuild/pull/408 . In theory CMake 3.16.3 is the one used on both Debian Sid and Ubuntu Focal, so the issue could be more tricky. For now @GiulioRomualdi @S-Dafarra feel free to ignore the problem (we can also close this issue), in the weekend I will probably spin a Debian Sid image on Docker or WSL to understand what's going on.

GiulioRomualdi commented 4 years ago

I also tried with a clean version of Debian stable everything seems ok

traversaro commented 4 years ago

I also tried with a clean version of Debian stable everything seems ok

This confirms that probably there is something due to a new package that is just on Debian sid. In practice no one uses Debian sid, but I placed that build exactly to catch this kind of errors before they arrive to system we actually uses (Debian Stable or Ubuntu LTS). However, for now we ignore it.

traversaro commented 4 years ago

Sorry for the noise, the CI failure is indeed in debian:stable docker image, not debian:sid .

traversaro commented 4 years ago

So, the problem is on Debian Stable because by default Debian Stable uses CMake 3.13, and in CMake 3.13 find_dependency(Eigen3 CONFIG) does nothing if Eigen3_FOUND is already defined and set to TRUE, and in our case it was already defined by the FindEigen3.cmake script that did not defined the Eigen3::Eigen imported target. In any case, devising a workaround for this problem is probably not worth it, and I will instead just fix iDynTree.

traversaro commented 4 years ago

Final fix proposed in https://github.com/robotology/idyntree/pull/691 .

GiulioRomualdi commented 4 years ago

robotology/idyntree#691 fixes the problem. So I close this issue. Feel free to reopen it again.