coin-or / qpOASES

Open-source C++ implementation of the recently proposed online active set strategy
GNU Lesser General Public License v2.1
365 stars 127 forks source link

Name conflict when compiling with other C++ code using LAPACK #60

Closed svigerske closed 4 years ago

svigerske commented 4 years ago

Issue created by migration from Trac.

Original creator: mkatliar

Original creation time: 2017-01-24 16:34:25

Assignee: ferreau

Version: 3.2.0

Example:

#include <blaze/Math.h>
#include <qpOASES.hpp>

int main(int, char **)
{
    return 0;
}

Compiler output:

In file included from /usr/local/include/qpOASES/QProblemB.hpp:44:0,
                 from /usr/local/include/qpOASES.hpp:59,
                 from test.cpp:3:
/usr/local/include/qpOASES/Matrices.hpp:96:7: error: conflicting declaration of C function ‘void dpotrf_(const char*, const long unsigned int*, double*, const long unsigned int*, long int*)’
  void dpotrf_ ( const char *, const unsigned long *, double *, const unsigned long *, long * );
       ^~~~~~~
In file included from /usr/local/include/blaze/math/lapack/potrf.h:51:0,
                 from /usr/local/include/blaze/math/dense/Inversion.h:57,
                 from /usr/local/include/blaze/math/DenseMatrix.h:44,
                 from /usr/local/include/blaze/math/CustomMatrix.h:45,
                 from /usr/local/include/blaze/Math.h:51,
                 from test.cpp:1:
/usr/local/include/blaze/math/lapack/clapack/potrf.h:58:6: note: previous declaration ‘void dpotrf_(char*, int*, double*, int*, int*)’
 void dpotrf_( char* uplo, int* n, double* A, int* lda, int* info );
      ^~~~~~~
In file included from /usr/local/include/qpOASES/QProblemB.hpp:44:0,
                 from /usr/local/include/qpOASES.hpp:59,
                 from test.cpp:3:
/usr/local/include/qpOASES/Matrices.hpp:98:7: error: conflicting declaration of C function ‘void spotrf_(const char*, const long unsigned int*, float*, const long unsigned int*, long int*)’
  void spotrf_ ( const char *, const unsigned long *, float *, const unsigned long *, long * );
       ^~~~~~~
In file included from /usr/local/include/blaze/math/lapack/potrf.h:51:0,
                 from /usr/local/include/blaze/math/dense/Inversion.h:57,
                 from /usr/local/include/blaze/math/DenseMatrix.h:44,
                 from /usr/local/include/blaze/math/CustomMatrix.h:45,
                 from /usr/local/include/blaze/Math.h:51,
                 from test.cpp:1:
/usr/local/include/blaze/math/lapack/clapack/potrf.h:57:6: note: previous declaration ‘void spotrf_(char*, int*, float*, int*, int*)’
 void spotrf_( char* uplo, int* n, float*  A, int* lda, int* info );
      ^~~~~~~
In file included from /usr/local/include/qpOASES.hpp:62:0,
                 from test.cpp:3:
/usr/local/include/qpOASES/SQProblemSchur.hpp:87:7: error: conflicting declaration of C function ‘void dtrtrs_(const char*, const char*, const char*, const long unsigned int*, const long unsigned int*, double*, const long unsigned int*, double*, const long unsigned int*, long int*)’
  void dtrtrs_( const char *UPLO, const char *TRANS, const char *DIAG, const unsigned long *N, const unsigned long *NRHS,
       ^~~~~~~
In file included from /usr/local/include/blaze/math/lapack/trtrs.h:52:0,
                 from /usr/local/include/blaze/math/LAPACK.h:74,
                 from /usr/local/include/blaze/Math.h:64,
                 from test.cpp:1:
/usr/local/include/blaze/math/lapack/clapack/trtrs.h:58:6: note: previous declaration ‘void dtrtrs_(char*, char*, char*, int*, int*, double*, int*, double*, int*, int*)’
 void dtrtrs_( char* uplo, char* trans, char* diag, int* n, int* nrhs, double* A, int* lda, double* B, int* ldb, int* info );
      ^~~~~~~
In file included from /usr/local/include/qpOASES.hpp:62:0,
                 from test.cpp:3:
/usr/local/include/qpOASES/SQProblemSchur.hpp:90:7: error: conflicting declaration of C function ‘void strtrs_(const char*, const char*, const char*, const long unsigned int*, const long unsigned int*, float*, const long unsigned int*, float*, const long unsigned int*, long int*)’
  void strtrs_( const char *UPLO, const char *TRANS, const char *DIAG, const unsigned long *N, const unsigned long *NRHS,
       ^~~~~~~
In file included from /usr/local/include/blaze/math/lapack/trtrs.h:52:0,
                 from /usr/local/include/blaze/math/LAPACK.h:74,
                 from /usr/local/include/blaze/Math.h:64,
                 from test.cpp:1:
/usr/local/include/blaze/math/lapack/clapack/trtrs.h:57:6: note: previous declaration ‘void strtrs_(char*, char*, char*, int*, int*, float*, int*, float*, int*, int*)’
 void strtrs_( char* uplo, char* trans, char* diag, int* n, int* nrhs, float*  A, int* lda, float*  B, int* ldb, int* info );
      ^~~~~~~

The compiler error is cause by LAPACK functions (dpotrf_ etc.) declared differently in qpOASES headers and Blaze headers.

Proposed solution: LAPACK function and macro declarations are not a part of the qpOASES interface. Therefore, I propose:

svigerske commented 4 years ago

Comment by ferreau created at 2017-03-28 08:33:17

Changing status from new to assigned.

svigerske commented 4 years ago

Comment by ferreau created at 2017-03-28 13:48:59

Thanks for your suggestions. The additional header has been introduced in revsion 232 of trunk and will become part of release 3.2.1.

svigerske commented 4 years ago

Comment by ferreau created at 2017-03-28 13:48:59

Resolution: fixed