MinGW:与LAPACK和BLAS链接会导致C ++异常被处理 [英] MinGW: Linking with LAPACK and BLAS causes C++ exceptions to become unhandled

查看:334
本文介绍了MinGW:与LAPACK和BLAS链接会导致C ++异常被处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况很简单,但很奇怪。当我编译我的程序没有LinearAlgebra.o源(需要链接到LAPACK),C ++异常被捕获和处理。当我不包括编译单元但仍链接到库( -llapack -lblas )时,捕获和处理异常。但是一旦我得到它(代码从它运行正常),C ++异常不再正确处理,我得到Windows崩溃处理程序程序已停止响应报告回HQ废话。

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.

我怀疑这是关于调用FORTRAN例程,导致C ++异常停止工作。但我不知道如何去修复这个。

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.

更新:

我很高兴找到了这个问题的临时解决方法:我使用MinGW gfortran 编译器直接编译我目前使用的LAPACK和BLAS例程。

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.

使用 -lgfortran 将这些目标文件链接到我的C ++项目中 g ++ 工作正常,我的例外仍然被正确处理!作为一个奖励,这允许我只包括我打算使用的LAPACK例程,所以现在我不再需要链接一个〜4MB的库。

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.

编辑:我认为if我静态链接库只是抓住它需要的所以它是4MB在这种情况下没有关系。

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

推荐答案

我用GotoBLAS2取得了不错的效果。运行包括脚本的脚本产生了一个大大的19MB静态库为我的机器优化。它通过简单地链接它完美无瑕。所有我的fortran风格的调用只是工作。

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.

这篇关于MinGW:与LAPACK和BLAS链接会导致C ++异常被处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆