1

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;
}`
Duke Le
  • 332
  • 3
  • 14
  • 3
    You should post the compiler errors. -- *What compilers should I download to use Eigen C++ ?* -- I doubt Eigen would fail to compile with any C++14 compliant compiler. – PaulMcKenzie Dec 11 '19 at 15:58
  • On Linux, I never had problems compiling Eigen with gcc. It is likely that the problem is not in compiler selection – Damien Dec 11 '19 at 16:03
  • The eigen library works well with the g++ compiler! What are the errors you get? – Uninitialized Dec 11 '19 at 16:04
  • Please provide a complete and simple test programme – Damien Dec 11 '19 at 16:07
  • I will try to add as many error examples as I can. Thanks everyone for instant respond :D – Duke Le Dec 11 '19 at 16:07
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Alan Birtles Dec 11 '19 at 16:07
  • 2
    Please show the full code you are compiling, including all files in the project and the compiler command line you are invoking and the complete compiler output verbatim. – walnut Dec 11 '19 at 16:13
  • I have just downloaded the "Basic linear solving example" from your first link. No problem here to compile with gcc on Linux and execute it. – Damien Dec 11 '19 at 16:25
  • I just gave an answer for the question. It turns out that the compiler actually work, but Codeblock always give the error in update 2, which is annoying because it makes the program outputs a whole lot of messages and takes 30+ seconds to compile. – Duke Le Dec 11 '19 at 16:37
  • Found the solution, thank you everyone! – Duke Le Dec 11 '19 at 16:47

1 Answers1

1

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.

Duke Le
  • 332
  • 3
  • 14
  • *"So now the question is"* If you have a new question, ask a separate question. *"skipping 3 instantiation contexts"* This has to be a part of a longer error/warning message. You're probably looking at the "Build messages" tab; open "Build log" to see the entire message. – HolyBlackCat Dec 11 '19 at 16:38
  • Anyway, I found the solution. It was such a stupid error with the warning setting. Thank you for your help! – Duke Le Dec 11 '19 at 16:46
  • 2
    @user3192711 For the next time you ask a question: This is exactly the reason we ask for the full compiler output and complete compiler invocation. Seeing that would have made the problem obvious immediately. – walnut Dec 11 '19 at 18:01