3

The situation is simple, but strange. When i compile my program without the LinearAlgebra.o source (which requires linking to LAPACK), C++ exceptions are caught and handled. When I do not include that compilation unit but still link to the libraries (-llapack -lblas), exceptions are caught and handled. But once I get it in there (the code from it runs just fine), C++ exceptions are no longer handled correctly, and I get Windows crash handler "Program has stopped responding report back to HQ" nonsense.

Here I shed light on what is going on inside this source file. I did keep it pretty simple, but I'm not sure if it's really Kosher.

I suspect it is something about invoking FORTRAN routines which causes C++ exceptions to stop working. But I have no idea how to go about fixing this.

UPDATE:

I am very glad to have found a temporary workaround for this issue: I am using MinGW's gfortran compiler to directly compile the LAPACK and BLAS routines I am currently using.

Linking those object files into my C++ project using -lgfortran with g++ works flawlessly, and my exceptions are still being correctly handled! As a bonus this allows me to only include what LAPACK routines I intend to use, so now I no longer have to link a ~4MB library.

Edit: I think if I statically link a library it only "grabs what it needs" so it being 4MB wouldn't matter in that case.

Community
  • 1
  • 1
Steven Lu
  • 41,389
  • 58
  • 210
  • 364
  • 1
    Usually, fortran code should be compiled using the `gfortran` front-end. It adds the appropriate flags to the compiler that using `gcc` and the language autodiscover feature does not. You can check the exact arguments used in the compilation compiling with the verbose option `-v`. – rodrigo Dec 27 '11 at 21:19

1 Answers1

0

I have had great results with GotoBLAS2. Running the script included produces a massive 19MB static library optimized for my machine. It works flawlessly by simply linking it. All of my fortran style calls just work.

Steven Lu
  • 41,389
  • 58
  • 210
  • 364