MinGW: Linking with LAPACK and BLAS causes C++ exceptions to become unhandled

蓝咒 提交于 2019-12-11 02:48:12

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8640644/mingw-linking-with-lapack-and-blas-causes-c-exceptions-to-become-unhandled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!