1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Mac (Intel cpu)でEigenがコンパイルエラー

Posted at

C++の数値計算コードの中で Eigen を利用しているが、最近からエラーがでてビルドできなくなった。(エラーはNumTraits.h, Complex.h, MathFunctions.h, XprHelper.h などに。)

Use of overloaded operator '*' is ambiguous (with operand types 'int' and 'Eigen::GenericNumTraits<float>::(unnamed enum at /usr/local/Cellar/eigen/3.4.0_1/include/eigen3/Eigen/src/Core/NumTraits.h:154:3)')
...
No matching function for call to 'pload'
...
Cannot take the address of an rvalue of type 'typename Eigen::internal::real_ref_retval<typename Eigen::internal::global_math_functions_filtering_base<complex<float>>::type>::type' (aka 'int')
...
Multiple overloads of 'run' instantiate to the same signature 'const Eigen::internal::real_ref_impl<const std::complex<float>>::RealScalar &(const std::complex<float> &)' (aka 'const std::complex<float> &(const std::complex<float> &)')
...
No viable conversion from 'const Eigen::SparseMatrix<double, 1>' to 'OtherCopy' (aka 'int')

現象
Intel CPUの Mac でこの問題が発生して、M1 Macでは問題なくビルドできた。おそらく clang-1316.0.21.2 にアップデートされた後の現象。

解決策
Eigenのヘッダファイルを先に読み込むように順番を入れ替えたら解決した。(SuiteSparse や MersenneTwister なども使っていて、何らかの干渉があるのだろうけどまだ原因を特定できていない)

Eigen のFAQにそのような記述があった。
https://eigen.tuxfamily.org/index.php?title=FAQ#Compilation

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?