编译安装osqp-eigen库的过程一直报错,网上搜索也没发现什么类似的原因。后来仔细看了两个库的项目仓库,发现原因可能是两个库的版本不匹配,osqp库比较新(该库一直在频繁更新),而osqp-eigen库比较旧(更新频率较慢),还未对于新版进行适配。因而,尝试下载旧版的osqp库,之后osqp-eigen库的编译安装就正常通过了。

测试时间:2023年6月12日

1 背景

1.1 osqp

osqp 是一种二次规划求解器,可用求解线性组合或二次规划问题,在同类问题中求解效率极高!

osqp 官网:https://osqp.org/,其C语言版本由 oxford 大学开发。

1.2 osqp-eigen

osqp-eigen 是对 osqp 库的 eigen 接口封装,使其更加好用。

osqp 是用纯 C 实现的,但是纯 C 中对于矩阵和向量的操作不是特别友好,因此为了更方便使用 osqp,在构造 C++ 接口时,引入了 Eigen 库,方便矩阵和向量的操作。

注意官方支持 python 和 matlab,无 C++ 接口,但给出两个推荐的第三方社区维护的接口:

osqp-cpp 与 osqp-eigen 类似,区别如下:

license:osqp-cpp 为 MIT(最宽松),osqp-eigen 为 LGPL(传染式开源)
dependency:两者除都依赖 Eigen 以外, osqp-cpp 依赖 google 自家的 abseil-cpp 库,osqp-eigen 没有其他依赖。
推荐使用 osqp-eigen 作为 osqp 的 C++ 接口。

1.3 参考

[1] 【OSQP】系列(1)——OSQP的安装与使用

[2] OSQP使用说明

2 安装方法

由于已经在安装ros时已经自带了eigen库,这里不再安装。

osqp-eigen 依赖于 osqp 库,osqp 依赖于 eigen 库,故建议的安装顺序如下:(1)eigen;(2)osqp;(3)osqp-eigen

2.1 osqp库安装

这里需要指定版本,不指定的话,后面编译安装 osqp-eigen 库时会报错。等后续 osqp-eigen 的版本更新,对新版的 osqp 库适配后应该就可以不用再指定了。

git clone --recursive -b release-0.6.3 https://github.com/oxfordcontrol/osqp.git
cd osqp
mkdir build && cd build
cmake .. 
make
sudo make install

2.2 osqp-eigen安装

测试时间为 2023 年 06 月 12 日,osqp-eigen 的最新版本为 v0.8.0,其能够适配 osqp 的版本为 v0.6.3

git clone https://github.com/robotology/osqp-eigen.git
cd osqp-eigen
mkdir build && cd build
cmake .. 
make
sudo make install

3 报错部分截图

如果不指定 osqp 的安装版本,在编译安装 osqp-eigen 库时会报错,报错的部分截图如下。

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

4 完整的报错记录

sudo make install

Scanning dependencies of target OsqpEigen
[ 20%] Building CXX object CMakeFiles/OsqpEigen.dir/src/Data.cpp.o
In file included from /home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:18,
                 from /home/hahaha/osqp-eigen/src/Data.cpp:12:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:42:37: error: ‘csc’ has not been declared
   42 |                                     csc*& osqpSparseMatrix);
      |                                     ^~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:51:56: error: ‘csc’ does not name a type
   51 |         bool osqpSparseMatrixToEigenSparseMatrix(const csc* const & osqpSparseMatrix,
      |                                                        ^~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:61:47: error: ‘csc’ does not name a type
   61 |         bool osqpSparseMatrixToTriplets(const csc* const & osqpSparseMatrix,
      |                                               ^~~
In file included from /home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:76,
                 from /home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:18,
                 from /home/hahaha/osqp-eigen/src/Data.cpp:12:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:12:62: error: ‘csc’ has not been declared
   12 |                                                              csc*& osqpSparseMatrix)
      |                                                              ^~~
In file included from /home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.hpp:76,
                 from /home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:18,
                 from /home/hahaha/osqp-eigen/src/Data.cpp:12:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp: In function ‘bool OsqpEigen::SparseMatrixHelper::createOsqpSparseMatrix(const Eigen::SparseCompressedBase<Derived>&, int*&)’:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:18:5: error: ‘c_int’ was not declared in this scope; did you mean ‘u_int’?
   18 |     c_int rows = colMajorCopy.rows();
      |     ^~~~~
      |     u_int
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:19:10: error: expected ‘;’ before ‘cols’
   19 |     c_int cols = colMajorCopy.cols();
      |          ^~~~~
      |          ;
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:20:10: error: expected ‘;’ before ‘numberOfNonZeroCoeff’
   20 |     c_int numberOfNonZeroCoeff = colMajorCopy.nonZeros();
      |          ^~~~~~~~~~~~~~~~~~~~~
      |          ;
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:34:36: error: ‘rows’ was not declared in this scope
   34 |     osqpSparseMatrix = csc_spalloc(rows, cols, numberOfNonZeroCoeff, 1, 0);
      |                                    ^~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:34:42: error: ‘cols’ was not declared in this scope; did you mean ‘cosl’?
   34 |     osqpSparseMatrix = csc_spalloc(rows, cols, numberOfNonZeroCoeff, 1, 0);
      |                                          ^~~~
      |                                          cosl
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:34:48: error: ‘numberOfNonZeroCoeff’ was not declared in this scope
   34 |     osqpSparseMatrix = csc_spalloc(rows, cols, numberOfNonZeroCoeff, 1, 0);
      |                                                ^~~~~~~~~~~~~~~~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:34:24: error: there are no arguments to ‘csc_spalloc’ that depend on a template parameter, so a declaration of ‘csc_spalloc’ must be available [-fpermissive]
   34 |     osqpSparseMatrix = csc_spalloc(rows, cols, numberOfNonZeroCoeff, 1, 0);
      |                        ^~~~~~~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:34:24: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:39:31: error: request for member ‘p’ in ‘osqpSparseMatrix->’, which is of non-class type ‘int’
   39 |             osqpSparseMatrix->p[k] = static_cast<c_int>(outerIndexPtr[k]);
      |                               ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:39:50: error: ‘c_int’ does not name a type; did you mean ‘u_int’?
   39 |             osqpSparseMatrix->p[k] = static_cast<c_int>(outerIndexPtr[k]);
      |                                                  ^~~~~
      |                                                  u_int
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:42:35: error: request for member ‘p’ in ‘osqpSparseMatrix->’, which is of non-class type ‘int’
   42 |                 osqpSparseMatrix->p[k] = 0;
      |                                   ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:44:35: error: request for member ‘p’ in ‘osqpSparseMatrix->’, which is of non-class type ‘int’
   44 |                 osqpSparseMatrix->p[k] = osqpSparseMatrix->p[k-1] + innerNonZerosPtr[k-1];
      |                                   ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:44:60: error: request for member ‘p’ in ‘osqpSparseMatrix->’, which is of non-class type ‘int’
   44 |                 osqpSparseMatrix->p[k] = osqpSparseMatrix->p[k-1] + innerNonZerosPtr[k-1];
      |                                                            ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:48:31: error: request for member ‘i’ in ‘osqpSparseMatrix->’, which is of non-class type ‘int’
   48 |             osqpSparseMatrix->i[innerOsqpPosition] = static_cast<c_int>(it.row());
      |                               ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:48:66: error: ‘c_int’ does not name a type; did you mean ‘u_int’?
   48 |          osqpSparseMatrix->i[innerOsqpPosition] = static_cast<c_int>(it.row());
      |                                                               ^~~~~
      |                                                               u_int
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:49:31: error: request for member ‘x’ in ‘osqpSparseMatrix->’, which is of non-class type ‘int’
   49 |             osqpSparseMatrix->x[innerOsqpPosition] = static_cast<c_float>(it.value());
      |                               ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:49:66: error: ‘c_float’ does not name a type; did you mean ‘float’?
   49 |         osqpSparseMatrix->x[innerOsqpPosition] = static_cast<c_float>(it.value());
      |                                                              ^~~~~~~
      |                                                              float
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:53:23: error: request for member ‘p’ in ‘osqpSparseMatrix->’, which is of non-class type ‘int’
   53 |     osqpSparseMatrix->p[static_cast<int>(cols)] = static_cast<c_int>(innerOsqpPosition);
      |                       ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:53:63: error: ‘c_int’ does not name a type; did you mean ‘u_int’?
   53 |    osqpSparseMatrix->p[static_cast<int>(cols)] = static_cast<c_int>(innerOsqpPosition);
      |                                                              ^~~~~
      |                                                              u_int
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp: At global scope:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:61:70: error: ‘csc’ does not name a type
   61 | pEigen::SparseMatrixHelper::osqpSparseMatrixToTriplets(const csc* const & osqpSparseMatrix,
      |                                                              ^~~

/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp: In function ‘bool OsqpEigen::SparseMatrixHelper::osqpSparseMatrixToTriplets(const int* const&, std::vector<Eigen::Triplet<T> >&)’:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:72:5: error: ‘c_int’ was not declared in this scope; did you mean ‘u_int’?
   72 |     c_int* innerIndexPtr = osqpSparseMatrix->i;
      |     ^~~~~
      |     u_int
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:72:12: error: ‘innerIndexPtr’ was not declared in this scope
   72 |     c_int* innerIndexPtr = osqpSparseMatrix->i;
      |            ^~~~~~~~~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:72:46: error: request for member ‘i’ in ‘osqpSparseMatrix->’, which is of non-class type ‘const int’
   72 |     c_int* innerIndexPtr = osqpSparseMatrix->i;
      |                                              ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:73:12: error: ‘outerIndexPtr’ was not declared in this scope
   73 |     c_int* outerIndexPtr = osqpSparseMatrix->p;
      |            ^~~~~~~~~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:73:46: error: request for member ‘p’ in ‘osqpSparseMatrix->’, which is of non-class type ‘const int’
   73 |     c_int* outerIndexPtr = osqpSparseMatrix->p;
      |                                              ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:76:5: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
   76 |     c_float* valuePtr = osqpSparseMatrix->x;
      |     ^~~~~~~
      |     float
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:76:14: error: ‘valuePtr’ was not declared in this scope
   76 |     c_float* valuePtr = osqpSparseMatrix->x;
      |              ^~~~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:76:43: error: request for member ‘x’ in ‘osqpSparseMatrix->’, which is of non-class type ‘const int’
   76 |     c_float* valuePtr = osqpSparseMatrix->x;
      |                                           ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:77:10: error: expected ‘;’ before ‘numberOfNonZeroCoeff’
   77 |     c_int numberOfNonZeroCoeff =  osqpSparseMatrix->p[osqpSparseMatrix->n];
      |          ^~~~~~~~~~~~~~~~~~~~~
      |          ;
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:82:12: error: expected ‘;’ before ‘value’
   82 |     c_float value;
      |            ^~~~~~
      |            ;
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:84:24: error: ‘numberOfNonZeroCoeff’ was not declared in this scope
   84 |     tripletList.resize(numberOfNonZeroCoeff);
      |                        ^~~~~~~~~~~~~~~~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:87:9: error: ‘value’ was not declared in this scope
   87 |         value = valuePtr[i];
      |         ^~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp: At global scope:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:101:79: error: ‘csc’ does not name a type
  101 | parseMatrixHelper::osqpSparseMatrixToEigenSparseMatrix(const csc* const & osqpSparseMatrix,
      |                                                              ^~~

/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp: In function ‘bool OsqpEigen::SparseMatrixHelper::osqpSparseMatrixToEigenSparseMatrix(const int* const&, Eigen::SparseMatrix<Scalar>&)’:
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:112:34: error: request for member ‘m’ in ‘osqpSparseMatrix->’, which is of non-class type ‘const int’
  112 |     int rows = osqpSparseMatrix->m;
      |                                  ^
/home/hahaha/osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp:113:34: error: request for member ‘n’ in ‘osqpSparseMatrix->’, which is of non-class type ‘const int’
  113 |     int cols = osqpSparseMatrix->n;
      |                                  ^
In file included from /home/hahaha/osqp-eigen/src/Data.cpp:12:
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp: At global scope:
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:30:9: error: ‘OSQPData’ does not name a type
   30 |         OSQPData *m_data; /**< OSQPData struct. */
      |         ^~~~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:96:51: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
   96 |         bool setGradient(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> gradientVector);
      |                                                   ^~~~~~~
      |                                                   float
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:96:76: error: template argument 1 is invalid
   96 | etGradient(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> gradientVector);
      |                                                              ^

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:96:77: error: template argument 1 is invalid
   96 | tGradient(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> gradientVector);
      |                                                              ^~

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:96:77: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:98:23: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
   98 |         Eigen::Matrix<c_float, Eigen::Dynamic, 1> getGradient();
      |                       ^~~~~~~
      |                       float
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:98:49: error: template argument 1 is invalid
   98 |         Eigen::Matrix<c_float, Eigen::Dynamic, 1> getGradient();
      |                                                 ^
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:116:53: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  116 |         bool setLowerBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBoundVector);
      |                                                     ^~~~~~~
      |                                                     float
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:116:78: error: template argument 1 is invalid
  116 | LowerBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBoundVector);
      |                                                              ^

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:116:79: error: template argument 1 is invalid
  116 | owerBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBoundVector);
      |                                                              ^~

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:116:79: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:126:53: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  126 |         bool setUpperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBoundVector);
      |                                                     ^~~~~~~
      |                                                     float
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:126:78: error: template argument 1 is invalid
  126 | UpperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBoundVector);
      |                                                              ^

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:126:79: error: template argument 1 is invalid
  126 | pperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBoundVector);
      |                                                              ^~

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:126:79: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:137:49: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  137 |         bool setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
      |                                                 ^~~~~~~
      |                                                 float
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:137:74: error: template argument 1 is invalid
  137 | ool setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
      |                                                                 ^

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:137:75: error: template argument 1 is invalid
  137 | ool setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
      |                                                                  ^~

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:137:75: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:138:49: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  138 |                        Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound);
      |                                                 ^~~~~~~
      |                                                 float
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:138:74: error: template argument 1 is invalid
  138 |              Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound);
      |                                                                ^

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:138:75: error: template argument 1 is invalid
  138 |              Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound);
      |                                                                 ^~

/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:138:75: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:144:9: error: ‘OSQPData’ does not name a type
  144 |         OSQPData *const & getData() const;
      |         ^~~~~~~~
In file included from /home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:154,
                 from /home/hahaha/osqp-eigen/src/Data.cpp:12:
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.tpp: In member function ‘bool OsqpEigen::Data::setHessianMatrix(const Eigen::SparseCompressedBase<Derived>&)’:
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.tpp:30:34: error: ‘m_data’ was not declared in this scope
   30 |     if ((hessianMatrix.rows() != m_data->n) || (hessianMatrix.cols()!= m_data->n)){
      |                                  ^~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.tpp:39:93: error: ‘m_data’ was not declared in this scope
   39 | MatrixHelper::createOsqpSparseMatrix(hessianMatrixUpperTriangular, m_data->P)){
      |                                                                    ^~~~~~

In file included from /home/hahaha/osqp-eigen/include/OsqpEigen/Data.hpp:154,
                 from /home/hahaha/osqp-eigen/src/Data.cpp:12:
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.tpp: In member function ‘bool OsqpEigen::Data::setLinearConstraintsMatrix(const Eigen::SparseCompressedBase<Derived>&)’:
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.tpp:70:44: error: ‘m_data’ was not declared in this scope
   70 |     if ((linearConstraintsMatrix.rows() != m_data->m) || (linearConstraintsMatrix.cols()!= m_data->n)){
      |                                            ^~~~~~
/home/hahaha/osqp-eigen/include/OsqpEigen/Data.tpp:78:65: error: ‘m_data’ was not declared in this scope
   78 |                                                                 m_data->A)){
      |                                                                 ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp: In constructor ‘OsqpEigen::Data::Data()’:
/home/hahaha/osqp-eigen/src/Data.cpp:24:5: error: ‘m_data’ was not declared in this scope
   24 |     m_data = (OSQPData *)c_malloc(sizeof(OSQPData));
      |     ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:24:15: error: ‘OSQPData’ was not declared in this scope
   24 |     m_data = (OSQPData *)c_malloc(sizeof(OSQPData));
      |               ^~~~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:24:25: error: expected primary-expression before ‘)’ token
   24 |     m_data = (OSQPData *)c_malloc(sizeof(OSQPData));
      |                         ^
/home/hahaha/osqp-eigen/src/Data.cpp: In constructor ‘OsqpEigen::Data::Data(int, int)’:
/home/hahaha/osqp-eigen/src/Data.cpp:38:5: error: ‘m_data’ was not declared in this scope
   38 |     m_data = (OSQPData *)c_malloc(sizeof(OSQPData));
      |     ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:38:15: error: ‘OSQPData’ was not declared in this scope
   38 |     m_data = (OSQPData *)c_malloc(sizeof(OSQPData));
      |               ^~~~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:38:25: error: expected primary-expression before ‘)’ token
   38 |     m_data = (OSQPData *)c_malloc(sizeof(OSQPData));
      |                         ^
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘void OsqpEigen::Data::clearHessianMatrix()’:
/home/hahaha/osqp-eigen/src/Data.cpp:50:20: error: ‘m_data’ was not declared in this scope
   50 |         csc_spfree(m_data->P);
      |                    ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:50:9: error: ‘csc_spfree’ was not declared in this scope
   50 |         csc_spfree(m_data->P);
      |         ^~~~~~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘void OsqpEigen::Data::clearLinearConstraintsMatrix()’:
/home/hahaha/osqp-eigen/src/Data.cpp:59:20: error: ‘m_data’ was not declared in this scope
   59 |         csc_spfree(m_data->A);
      |                    ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:59:9: error: ‘csc_spfree’ was not declared in this scope
   59 |         csc_spfree(m_data->A);
      |         ^~~~~~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp: In destructor ‘OsqpEigen::Data::~Data()’:
/home/hahaha/osqp-eigen/src/Data.cpp:68:12: error: ‘m_data’ was not declared in this scope
   68 |     c_free(m_data);
      |            ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:68:5: error: ‘c_free’ was not declared in this scope; did you mean ‘free’?
   68 |     c_free(m_data);
      |     ^~~~~~
      |     free
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘void OsqpEigen::Data::setNumberOfVariables(int)’:
/home/hahaha/osqp-eigen/src/Data.cpp:74:5: error: ‘m_data’ was not declared in this scope
   74 |     m_data->n = n;
      |     ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘void OsqpEigen::Data::setNumberOfConstraints(int)’:
/home/hahaha/osqp-eigen/src/Data.cpp:80:5: error: ‘m_data’ was not declared in this scope
   80 |     m_data->m = m;
      |     ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp: At global scope:
/home/hahaha/osqp-eigen/src/Data.cpp:83:1: error: ‘OSQPData’ does not name a type
   83 | OSQPData* const & OsqpEigen::Data::getData() const
      | ^~~~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘bool OsqpEigen::Data::isSet() const’:
/home/hahaha/osqp-eigen/src/Data.cpp:90:36: error: ‘m_data’ was not declared in this scope
   90 |     const bool areConstraintsOk = (m_data->m == 0) ||
      |                                    ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp: At global scope:
/home/hahaha/osqp-eigen/src/Data.cpp:102:60: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  102 | bool OsqpEigen::Data::setGradient(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> gradient)
      |                                                            ^~~~~~~
      |                                                            float
/home/hahaha/osqp-eigen/src/Data.cpp:102:85: error: template argument 1 is invalid
  102 | ta::setGradient(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> gradient)
      |                                                                   ^

/home/hahaha/osqp-eigen/src/Data.cpp:102:86: error: template argument 1 is invalid
  102 | ta::setGradient(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> gradient)
      |                                                                    ^~

/home/hahaha/osqp-eigen/src/Data.cpp:102:86: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘bool OsqpEigen::Data::setGradient(int)’:
/home/hahaha/osqp-eigen/src/Data.cpp:104:17: error: request for member ‘rows’ in ‘gradient’, which is of non-class type ‘int’
  104 |     if(gradient.rows() != m_data->n){
      |                 ^~~~
/home/hahaha/osqp-eigen/src/Data.cpp:104:27: error: ‘m_data’ was not declared in this scope
  104 |     if(gradient.rows() != m_data->n){
      |                           ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:110:5: error: ‘m_data’ was not declared in this scope
  110 |     m_data->q = gradient.data();
      |     ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:110:26: error: request for member ‘data’ in ‘gradient’, which is of non-class type ‘int’
  110 |     m_data->q = gradient.data();
      |                          ^~~~
/home/hahaha/osqp-eigen/src/Data.cpp: At global scope:
/home/hahaha/osqp-eigen/src/Data.cpp:114:15: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  114 | Eigen::Matrix<c_float, Eigen::Dynamic, 1> OsqpEigen::Data::getGradient()
      |               ^~~~~~~
      |               float
/home/hahaha/osqp-eigen/src/Data.cpp:114:41: error: template argument 1 is invalid
  114 | Eigen::Matrix<c_float, Eigen::Dynamic, 1> OsqpEigen::Data::getGradient()
      |                                         ^
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘int OsqpEigen::Data::getGradient()’:
/home/hahaha/osqp-eigen/src/Data.cpp:116:37: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  116 |     return Eigen::Map<Eigen::Matrix<c_float, Eigen::Dynamic, 1>>(m_data->q, m_data->n);
      |                                     ^~~~~~~
      |                                     float
/home/hahaha/osqp-eigen/src/Data.cpp:116:62: error: template argument 1 is invalid
  116 |     return Eigen::Map<Eigen::Matrix<c_float, Eigen::Dynamic, 1>>(m_data->q, m_data->n);
      |                                                              ^
/home/hahaha/osqp-eigen/src/Data.cpp:116:63: error: template argument 1 is invalid
  116 |    return Eigen::Map<Eigen::Matrix<c_float, Eigen::Dynamic, 1>>(m_data->q, m_data->n);
      |                                                              ^~

/home/hahaha/osqp-eigen/src/Data.cpp:116:66: error: ‘m_data’ was not declared in this scope
  116 | return Eigen::Map<Eigen::Matrix<c_float, Eigen::Dynamic, 1>>(m_data->q, m_data->n);
      |                                                              ^~~~~~

/home/hahaha/osqp-eigen/src/Data.cpp: At global scope:
/home/hahaha/osqp-eigen/src/Data.cpp:119:62: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  119 | bool OsqpEigen::Data::setLowerBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound)
      |                                                              ^~~~~~~
      |                                                              float
/home/hahaha/osqp-eigen/src/Data.cpp:119:87: error: template argument 1 is invalid
  119 | setLowerBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound)
      |                                                                 ^

/home/hahaha/osqp-eigen/src/Data.cpp:119:88: error: template argument 1 is invalid
  119 | setLowerBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound)
      |                                                                  ^~

/home/hahaha/osqp-eigen/src/Data.cpp:119:88: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘bool OsqpEigen::Data::setLowerBound(int)’:
/home/hahaha/osqp-eigen/src/Data.cpp:121:19: error: request for member ‘rows’ in ‘lowerBound’, which is of non-class type ‘int’
  121 |     if(lowerBound.rows() != m_data->m){
      |                   ^~~~
/home/hahaha/osqp-eigen/src/Data.cpp:121:29: error: ‘m_data’ was not declared in this scope
  121 |     if(lowerBound.rows() != m_data->m){
      |                             ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:127:5: error: ‘m_data’ was not declared in this scope
  127 |     m_data->l = lowerBound.data();
      |     ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:127:28: error: request for member ‘data’ in ‘lowerBound’, which is of non-class type ‘int’
  127 |     m_data->l = lowerBound.data();
      |                            ^~~~
/home/hahaha/osqp-eigen/src/Data.cpp: At global scope:
/home/hahaha/osqp-eigen/src/Data.cpp:131:62: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  131 | bool OsqpEigen::Data::setUpperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound)
      |                                                              ^~~~~~~
      |                                                              float
/home/hahaha/osqp-eigen/src/Data.cpp:131:87: error: template argument 1 is invalid
  131 | setUpperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound)
      |                                                                 ^

/home/hahaha/osqp-eigen/src/Data.cpp:131:88: error: template argument 1 is invalid
  131 | setUpperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound)
      |                                                                  ^~

/home/hahaha/osqp-eigen/src/Data.cpp:131:88: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/src/Data.cpp: In member function ‘bool OsqpEigen::Data::setUpperBound(int)’:
/home/hahaha/osqp-eigen/src/Data.cpp:133:19: error: request for member ‘rows’ in ‘upperBound’, which is of non-class type ‘int’
  133 |     if(upperBound.rows() != m_data->m){
      |                   ^~~~
/home/hahaha/osqp-eigen/src/Data.cpp:133:29: error: ‘m_data’ was not declared in this scope
  133 |     if(upperBound.rows() != m_data->m){
      |                             ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:139:5: error: ‘m_data’ was not declared in this scope
  139 |     m_data->u = upperBound.data();
      |     ^~~~~~
/home/hahaha/osqp-eigen/src/Data.cpp:139:28: error: request for member ‘data’ in ‘upperBound’, which is of non-class type ‘int’
  139 |     m_data->u = upperBound.data();
      |                            ^~~~
/home/hahaha/osqp-eigen/src/Data.cpp: At global scope:
/home/hahaha/osqp-eigen/src/Data.cpp:143:58: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  143 | bool OsqpEigen::Data::setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
      |                                                          ^~~~~~~
      |                                                          float
/home/hahaha/osqp-eigen/src/Data.cpp:143:83: error: template argument 1 is invalid
  143 | ta::setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
      |                                                                 ^

/home/hahaha/osqp-eigen/src/Data.cpp:143:84: error: template argument 1 is invalid
  143 | ta::setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
      |                                                                  ^~

/home/hahaha/osqp-eigen/src/Data.cpp:143:84: error: template argument 3 is invalid
/home/hahaha/osqp-eigen/src/Data.cpp:144:58: error: ‘c_float’ was not declared in this scope; did you mean ‘float’?
  144 |                                 Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound)
      |                                                          ^~~~~~~
      |                                                          float
/home/hahaha/osqp-eigen/src/Data.cpp:144:83: error: template argument 1 is invalid
  144 |               Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound)
      |                                                                 ^

/home/hahaha/osqp-eigen/src/Data.cpp:144:84: error: template argument 1 is invalid
  144 |               Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound)
      |                                                                  ^~

/home/hahaha/osqp-eigen/src/Data.cpp:144:84: error: template argument 3 is invalid
make[2]: *** [CMakeFiles/OsqpEigen.dir/build.make:63:CMakeFiles/OsqpEigen.dir/src/Data.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:124:CMakeFiles/OsqpEigen.dir/all] 错误 2
make: *** [Makefile:130:all] 错误 2

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐