You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

预编译LAPACK DLL无法在gfortran中运行的问题求助

Fortran中使用预编译LAPACK DLL求解线性方程组的问题

背景

我需要在Fortran中使用LAPACK求解线性方程组,但不熟悉自行编译LAPACK,因此尝试直接使用预编译库。我下载了32位和64位的liblapack.dll,重命名为lapack32.dll和lapack64.dll后放在Fortran代码同目录下,但不确定我的编译器是32位还是64位。

测试代码

我用以下测试代码testinv.f90验证安装:

Program LinearEquations
    ! solving the matrix equation A*x=b using LAPACK
    Implicit none
  
    ! declarations
    double precision :: A(3,3), b(3)
    integer :: i, pivot(3), ok

    ! Say we are alive:
    print*, 'Hi this is working!'
    
    ! matrix A
    A(1,:)=(/3, 1, 3/)
    A(2,:)=(/1, 5, 9/)
    A(3,:)=(/2, 6, 5/)
    
    ! vector b
    b(:)=(/-1, 3, -3/)
  
    ! find the solution using the LAPACK routine DGESV
    call DGESV(3, 1, A, 3, pivot, b, 3, ok)
  
    ! print the solution x
    do i=1,3
      write(*,9) i, b(i)
    end do  
  
    9 format('x[', i1, ']= ', f5.2)  
  end program LinearEquations

该程序预期输出Hi this is working!及线性方程组的3个解。

编译尝试及问题

我分别尝试了32位和64位编译命令,遇到以下问题:

  • 64位编译命令:

    gfortran -o testinv testinv.f90 -L. lapack64.dll; ./testinv.exe
    

    编译器报错:

    lapack64.dll: file not recognized: file format not recognized
    collect2.exe: error: ld returned 1 exit status
    
  • 32位编译命令:

    gfortran -o testinv testinv.f90 -L. lapack64.dll; ./testinv.exe
    

    编译成功生成testinv.exe,但运行后无任何输出。

疑问

请问我当前使用预编译LAPACK DLL的方式是否可行?或是遗漏了什么步骤?


内容的提问来源于stack exchange,提问作者Dhr. Beunhaas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 11:45:33