Eigen/Eigenvalues: Too many sections with mingw-w64
Asked Answered
B

0

9

I want to compile the following example based on Eigen's general eigenvalue solver (Eigen 3.3.3):

#include <iostream>
#include <Eigen/Eigenvalues>

int main()
{
    Eigen::Matrix4f A;
    A << -0.75, 0, -1.5, -1,
         -1.25, 0, -1.5, -1,
         -0.75, 0, -1,   -1,
         -0.25, 0, -1.5, -1;

    Eigen::Matrix4f G;
    G << 1, 0, 0, 0,
         0, 1, 0, 0,
         0, 0, 1, 0,
         0, 0, 0, 0;

    std::cout << "A = " << A << std::endl;
    std::cout << "G = " << G << std::endl;

    Eigen::GeneralizedEigenSolver<Eigen::Matrix4f> sol;

    sol.compute(A.transpose()*A, G); // compute generalized eigenvalues

    std::cout << "alphas = " << sol.alphas().transpose() << std::endl;
    std::cout << "betas = " << sol.betas().transpose() << std::endl;
    std::cout << "eigenvalues = " << sol.eigenvalues().transpose() << std::endl;
    std::cout << "eigenvectors = " << sol.eigenvectors() << std::endl;
}

It takes 53 seconds to compile this small example, but it builds without complains with g++ on Ubuntu (gcc version 5.4.0, Ubuntu 16.04).

If I try to compile it with mingw-w64 (gcc version 6.2.0 (x86_64-win32-seh-rev1, Built by MinGW-W64 project)) on Windows, the compiler says

as.exe: main.o: too many sections (48774)
Assembler messages:
Fatal error: can't write main.o: File too big

so I tried to add the compiler flag -Wa,-mbig-obj like suggested in this stackoverflow question.

With the flag enabled mingw-w64 compiles the example, but I canceled the build during linking after 1 hour. I've also tried to compile the example from Eigen's documentation. It takes around 3 minutes but builds completely with mingw-w64.

Due to this long build times this solution is not applicable if I want to use the general eigenvalue solver in a real application.

It seams that this problem is related to the template structure of Eigen which leads to many symbols in a single source files. It looks like that mingw is not very comfortable with this.

Is there a way to optimize this situation with mingw?

Barbarize answered 9/4, 2017 at 12:7 Comment(2)
Have you considered using more recent eigen 3.4.0 ?Astrogeology
I have the same issue with eigen 3.4.0Gentianella

© 2022 - 2024 — McMap. All rights reserved.