简体   繁体   中英

Which codeblock compiler is needed to use Eigen C++?

Currently, I use mingw32-g++.exe (GNU GCC Compiler) for codeblock, with -std=C++14. The compiler was downloaded here: http://www.codeblocks.org/downloads/26

However, all tutorial programs here fail to compile: https://eigen.tuxfamily.org/dox/group__TutorialLinearAlgebra.html

The #include has been done correctly. Only the compute lines such as

Matrix2f x = A.ldlt().solve(b); and Matrix2f x = A.ldlt().solve(b); fails. I also tried using the Intel C++ compiler, but it still fails.

What compilers should I download to use Eigen C++ ?

Thank you very much for your help

Update1: using the "Basic linear solving" example, I get this error:

File IndexedViewHelper.h:

"undefined reference to Eigen::fix<1>", line 57

"Undefined reference to Eigen::fix<0>"

Update 2: using the second example A.ldlt().solve(b) , I get this:

"[ skipping 3 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]", line 100

"[ skipping 3 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]", line 90

...

Update 3: Full code + compiler: Literally just one main.cpp file + add eigen folder to search directories

` #include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
   Matrix2f A, b;
   A << 2, -1, -1, 3;
   b << 1, 2, 3, 1;
   cout << "Here is the matrix A:\n" << A << endl;
   cout << "Here is the right hand side b:\n" << b << endl;
   Matrix2f x = A.ldlt().solve(b);
   cout << "The solution is:\n" << x << endl;
}`

Solution: I just notice that the program actually compile successfully, but it's just that it always gives the error "[ skipping 3 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]", line 100, file CoreEvaluators.h

So the regular MinGW compiler for Codeblock still works. It's just that it always give that error (+ 20-second long compile where it outputs a bunch of messages like the above).

Updated solution: OH MY GOD I FEEL SO STUPID. Disable the following warning:

Enable Effective-C++ warnings (thanks Scott Meyers) [-Weffc++].

The "errors" (actually warnings) are no longer spammed and the program compiles immediately. For some reasons theese warnings appear as error and cause the compilation process to stop suddenly (making it appears as failed). Pretty much an undebugable error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM