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

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

问题描述

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



这里我阐明了什么在这个源文件里面。我确实很简单,但我不知道是否真的是犹太人。



我怀疑这是调用FORTRAN例程,导致C ++异常停止工作。但我不知道如何解决这个问题。



更新:



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



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



编辑:我想如果我静态链接一个图书馆只是抓住它需要什么,所以它是4MB在这种情况下无关紧要。

解决方案

我在GotoBLAS2中取得了很好的成绩。运行包含的脚本可以为我的机器优化大量的19MB静态库。它通过简单地链接它完美无缺。我所有的fortran风格的电话都工作。


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.

解决方案

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天全站免登陆