Compilation error in OpenCV with latest commit (as of 2023/11/09) of 3.4 branch
Summary
Compiling opencv (https://opencv.org/) with -DWITH_EIGEN=ON
with the latest commit from Eigen 3.4 branch results in the following error:
2023-07-21T03:29:44.9175025Z [108/239] Building CXX object src/TSID/CMakeFiles/TSID.dir/src/FeasibleContactWrenchTask.cpp.o
2023-07-21T03:29:44.9175667Z [109/239] Building CXX object src/TSID/CMakeFiles/TSID.dir/src/VariableRegularizationTask.cpp.o
2023-07-21T03:29:44.9176347Z [110/239] Building CXX object src/Perception/CMakeFiles/PerceptionFeatures.dir/src/ArucoDetector.cpp.o
2023-07-21T03:29:44.9177005Z FAILED: src/Perception/CMakeFiles/PerceptionFeatures.dir/src/ArucoDetector.cpp.o
2023-07-21T03:29:44.9182744Z /usr/share/miniconda3/envs/test/bin/x86_64-conda-linux-gnu-c++ -DFMT_SHARED -DPerceptionFeatures_EXPORTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -D_USE_MATH_DEFINES -Dcasadi_VERSION=3.6.3 -I/home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/Perception/include -I/home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/ParametersHandler/include -I/home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/GenericContainer/include -I/home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/TextLogging/include -I/home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/Conversions/include -I/home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/System/include -isystem /home/runner/work/robotology-superbuild/robotology-superbuild/build/install/include -isystem /usr/share/miniconda3/envs/test/include/eigen3 -isystem /usr/share/miniconda3/envs/test/include/opencv4 -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /usr/share/miniconda3/envs/test/include -O3 -DNDEBUG -std=c++17 -fPIC -MD -MT src/Perception/CMakeFiles/PerceptionFeatures.dir/src/ArucoDetector.cpp.o -MF src/Perception/CMakeFiles/PerceptionFeatures.dir/src/ArucoDetector.cpp.o.d -o src/Perception/CMakeFiles/PerceptionFeatures.dir/src/ArucoDetector.cpp.o -c /home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/Perception/src/ArucoDetector.cpp
2023-07-21T03:29:44.9186878Z In file included from /usr/share/miniconda3/envs/test/include/eigen3/unsupported/Eigen/CXX11/Tensor:59,
2023-07-21T03:29:44.9187549Z from /usr/share/miniconda3/envs/test/include/opencv4/opencv2/core/eigen.hpp:64,
2023-07-21T03:29:44.9188694Z from /home/runner/work/robotology-superbuild/robotology-superbuild/src/bipedal-locomotion-framework/src/Perception/src/ArucoDetector.cpp:20:
2023-07-21T03:29:44.9189863Z /usr/share/miniconda3/envs/test/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h:266:91: error: 'First' was not declared in this scope; did you mean 'first'?
2023-07-21T03:29:44.9190594Z 266 | array<Index, 1 + sizeof...(Is)> customIndices2Array(IndexType& idx, numeric_list<Index, First, Is...>) {
2023-07-21T03:29:44.9191201Z | ^~~~~
2023-07-21T03:29:44.9191609Z | first
2023-07-21T03:29:44.9192192Z /usr/share/miniconda3/envs/test/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h:266:103: error: template argument 2 is invalid
2023-07-21T03:29:44.9192873Z 266 | array<Index, 1 + sizeof...(Is)> customIndices2Array(IndexType& idx, numeric_list<Index, First, Is...>) {
2023-07-21T03:29:44.9193485Z | ^
2023-07-21T03:29:44.9194616Z /usr/share/miniconda3/envs/test/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h: In function 'constexpr Eigen::array<Index, (1 + sizeof... (Is))> Eigen::internal::customIndices2Array(IndexType&, int)':
2023-07-21T03:29:44.9195700Z /usr/share/miniconda3/envs/test/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h:267:37: error: 'First' was not declared in this scope; did you mean 'first'?
2023-07-21T03:29:44.9196360Z 267 | return { static_cast<Index>(idx[First]), static_cast<Index>(idx[Is])... };
2023-07-21T03:29:44.9196794Z | ^~~~~
2023-07-21T03:29:44.9197149Z | first
2023-07-21T03:29:44.9197616Z [111/239] Building CXX object src/TSID/CMakeFiles/TSID.dir/src/QPFixedBaseTSID.cpp.o
2023-07-21T03:29:44.9198180Z [112/239] Building CXX object src/TSID/CMakeFiles/TSID.dir/src/QPTSID.cpp.o
According to the discussion in https://github.com/robotology/robotology-superbuild/issues/1446#issuecomment-1802640340 (that I still need to verify), this may be fixed by backporting the change done in !765 (merged) . If this is confirmed, are you interested in having this fix in 3.4 branch? Thanks a lot in advance!
Environment
- Operating System : Linux
- Architecture : x64
- Eigen Version : bae907b8
- Compiler Version : Gcc 12
- Compile Flags : -O3
- Vector Extension : SSE2
Minimal Example
See Steps to reproduce
Steps to reproduce
git clone https://gist.github.com/traversaro/3c505dc553cb6da3fedeae651d4fc648 eigen2745
cd eigen2745
# This fails (latest Eigen 3.4 as of 2023/11/09)
docker build --build-arg EIGEN_REPO=https://gitlab.com/libeigen/eigen.git --build-arg EIGEN_REF=bae907b8f6078b1df290729eef946360315bd312 -t opencv-eigen-image-not-working .
fails with:
[ 4%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o
In file included from /usr/local/include/eigen3/unsupported/Eigen/CXX11/Tensor:59,
from /usr/src/opencv/modules/core/include/opencv2/core/eigen.hpp:66,
from /usr/src/opencv/modules/core/include/opencv2/core/private.hpp:74,
from /usr/src/opencv/modules/core/src/precomp.hpp:59,
from /usr/src/opencv/modules/core/src/algorithm.cpp:43:
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h:266:91: error: 'First' was not declared in this scope; did you mean 'first'?
266 | array<Index, 1 + sizeof...(Is)> customIndices2Array(IndexType& idx, numeric_list<Index, First, Is...>) {
| ^~~~~
| first
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h:266:103: error: template argument 2 is invalid
266 | array<Index, 1 + sizeof...(Is)> customIndices2Array(IndexType& idx, numeric_list<Index, First, Is...>) {
| ^
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h: In function 'constexpr Eigen::array<Index, (1 + sizeof... (Is))> Eigen::internal::customIndices2Array(IndexType&, int)':
/usr/local/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h:267:37: error: 'First' was not declared in this scope; did you mean 'first'?
267 | return { static_cast<Index>(idx[First]), static_cast<Index>(idx[Is])... };
| ^~~~~
| first
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:103: modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1950: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
This instead works (fix provided in !1412 (merged)):
docker build --build-arg EIGEN_REPO=https://gitlab.com/dynamic-interaction-control/eigen.git --build-arg EIGEN_REF=fix2745 -t opencv-eigen-image-test1 .
What is the current bug behavior?
The compilation fails with an error.
What is the expected correct behavior?
The code compiles.
Relevant logs
See the error in the top
-
Have a plan to fix this issue: yes, see !1412 (merged) .
Edited by Silvio Traversaro