Conflicting BLAS types between eigen and Apple's Accelerate

Summary

When eigen is instructed to utilize BLAS through EIGEN_USE_BLAS and Accelerate.h is included, compiler errors are raised. A similar issue can be raised by importing <Eigen/SuperLUSupport> after EIGEN_USE_BLAS.

Environment

  • Operating System : MacOS 12.1
  • Architecture : Arm64 ...
  • Eigen Version : 3.4.0
  • Compiler Version : Apple clang version 13.0.0
  • Compile Flags : -g -std=c++11 -O3 -I/opt/local/include/eigen3 -framework Accelerate test.cpp -o test
  • Vector Extension : NEON ...

Minimal Example

#include <iostream>

#include <Accelerate/Accelerate.h>

#define EIGEN_USE_BLAS

#include <Eigen/Dense>
#include <Eigen/Sparse>

using namespace Eigen;

int main(void)
{
    Matrix4d m1 {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
    Matrix4d m2 {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
    std::cout << m1 * m2.transpose() << std::endl;
    m1.selfadjointView<Lower>() * m2;
    m1 * m2.triangularView<Upper>();
    m1.selfadjointView<Lower>().rankUpdate(m2,1.0);

    std::cout << m1 << std::endl;

    return 0;
}

Steps to reproduce

  1. Compile the code with: clang++ -g -std=c++11 -O3 -I/opt/local/include/eigen3 -framework Accelerate test.cpp -o test

What is the current bug behavior?

Many compiler errors are thrown regarding conflicting types, return types, etc.

What is the expected correct behavior?

The program should compile.

Relevant logs

Warning Messages

In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:21:8: error: functions that differ only in their return type cannot be overloaded
float  BLASFUNC(sdot)  (int *, float  *, int *, float  *, int *);
~~~~~  ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:111:1: note: expanded from here
sdot_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:85:8: note: previous declaration is here
double sdot_(int *n,
~~~~~~ ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:22:8: error: functions that differ only in their return type cannot be overloaded
float  BLASFUNC(sdsdot)(int *, float  *,        float  *, int *, float  *, int *);
~~~~~  ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:112:1: note: expanded from here
sdsdot_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:95:8: note: previous declaration is here
double sdsdot_(int *n, float *sb,
~~~~~~ ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:33:8: error: conflicting types for 'saxpy_'
int    BLASFUNC(saxpy) (const int *, const float  *, const float  *, const int *, float  *, const int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:120:1: note: expanded from here
saxpy_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:45:5: note: previous declaration is here
int saxpy_(int *n, float *da,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:34:8: error: conflicting types for 'daxpy_'
int    BLASFUNC(daxpy) (const int *, const double *, const double *, const int *, double *, const int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:121:1: note: expanded from here
daxpy_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:50:5: note: previous declaration is here
int daxpy_(int *n, double *da,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:36:8: error: conflicting types for 'caxpy_'
int    BLASFUNC(caxpy) (const int *, const float  *, const float  *, const int *, float  *, const int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:123:1: note: expanded from here
caxpy_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:55:5: note: previous declaration is here
int caxpy_(int *n, void *ca,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:37:8: error: conflicting types for 'zaxpy_'
int    BLASFUNC(zaxpy) (const int *, const double *, const double *, const int *, double *, const int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:124:1: note: expanded from here
zaxpy_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:60:5: note: previous declaration is here
int zaxpy_(int *n, void *ca,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:46:8: error: conflicting types for 'ccopy_'
int    BLASFUNC(ccopy) (int *, float  *, int *, float  *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:132:1: note: expanded from here
ccopy_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:75:5: note: previous declaration is here
int ccopy_(int *n,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:47:8: error: conflicting types for 'zcopy_'
int    BLASFUNC(zcopy) (int *, double *, int *, double *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:133:1: note: expanded from here
zcopy_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:80:5: note: previous declaration is here
int zcopy_(int *n,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:53:8: error: conflicting types for 'cswap_'
int    BLASFUNC(cswap) (int *, float  *, int *, float  *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:138:1: note: expanded from here
cswap_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:232:5: note: previous declaration is here
int cswap_(int *n,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:54:8: error: conflicting types for 'zswap_'
int    BLASFUNC(zswap) (int *, double *, int *, double *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:139:1: note: expanded from here
zswap_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:237:5: note: previous declaration is here
int zswap_(int *n,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:57:8: error: functions that differ only in their return type cannot be overloaded
float  BLASFUNC(sasum) (int *, float  *, int *);
~~~~~  ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:141:1: note: expanded from here
sasum_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:33:8: note: previous declaration is here
double sasum_(int *n, float *sx, int *incx)
~~~~~~ ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:58:8: error: functions that differ only in their return type cannot be overloaded
float  BLASFUNC(scasum)(int *, float  *, int *);
~~~~~  ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:142:1: note: expanded from here
scasum_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:39:8: note: previous declaration is here
double scasum_(int *n, void *cx, int *incx)
~~~~~~ ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:61:8: error: conflicting types for 'dzasum_'
double BLASFUNC(dzasum)(int *, double *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:145:1: note: expanded from here
dzasum_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:42:8: note: previous declaration is here
double dzasum_(int *n, void *cx, int *incx)
       ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:67:8: error: conflicting types for 'icamax_'
int    BLASFUNC(icamax)(int *, float  *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:150:1: note: expanded from here
icamax_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:27:5: note: previous declaration is here
int icamax_(int *n, void *cx, int *incx)
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:68:8: error: conflicting types for 'izamax_'
int    BLASFUNC(izamax)(int *, double *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:151:1: note: expanded from here
izamax_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:30:5: note: previous declaration is here
int izamax_(int *n, void *cx, int *incx)
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:123:8: error: conflicting types for 'cscal_'
int    BLASFUNC(cscal) (int *,  float  *, float  *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:198:1: note: expanded from here
cscal_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:206:5: note: previous declaration is here
int cscal_(int *n, void *ca,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:124:8: error: conflicting types for 'zscal_'
int    BLASFUNC(zscal) (int *,  double *, double *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:199:1: note: expanded from here
zscal_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:210:5: note: previous declaration is here
int zscal_(int *n, void *ca,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:126:8: error: conflicting types for 'csscal_'
int    BLASFUNC(csscal)(int *,  float  *, float  *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:201:1: note: expanded from here
csscal_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:214:5: note: previous declaration is here
int csscal_(int *n, float *sa,
    ^
In file included from test.cpp:7:
In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:54:
In file included from /opt/local/include/eigen3/Eigen/src/Core/util/MKL_support.h:120:
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:127:8: error: conflicting types for 'zdscal_'
int    BLASFUNC(zdscal)(int *,  double *, double *, int *);
       ^
/opt/local/include/eigen3/Eigen/src/Core/util/../../misc/blas.h:9:24: note: expanded from macro 'BLASFUNC'
#define BLASFUNC(FUNC) FUNC##_
                       ^
<scratch space>:202:1: note: expanded from here
zdscal_
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h:218:5: note: previous declaration is here
int zdscal_(int *n, double *sa,
    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Anything else that might help

  • Have a plan to fix this issue.