在Windows10 64位MSYS2环境下使用BLAS、LAPACK、ARPACK的编译咨询
dgelsx.f in MSYS2 MinGW64 Hey there, let's troubleshoot this compilation problem step by step. Since you're using OpenBLAS/LAPACK instead of Intel MKL (the original environment for that example), the main issues likely revolve around library linking or source code compatibility. Here's what you can try:
1. Correct Your Compilation Command
The most common mistake is not linking the required libraries, or using the wrong order (gfortran requires libraries to come after the source file). Use this command instead:
gfortran dgelsx.f -o dgelsx -llapack -lopenblas
If you want to make sure you're using the right library paths, use pkg-config to auto-generate the linker flags:
# First verify pkg-config can find your libraries pkg-config --libs lapack openblas # Then compile with those flags gfortran dgelsx.f -o dgelsx $(pkg-config --libs lapack openblas)
2. Remove MKL-Specific Dependencies from the Source
The dgelsx.f example from MKL might have hardcoded references to MKL's LAPACK interface. Open the file and check for lines like:
USE MKL_LAPACK
If you find this, replace it with:
USE LAPACK
Or comment it out entirely—this will tell the compiler to use the open-source LAPACK library you installed instead of MKL's version.
3. Verify Your Library Installation
Double-check that your OpenBLAS and LAPACK packages are fully installed and not corrupted:
pacman -S --reinstall mingw-w64-x86_64-openblas mingw-w64-x86_64-lapack
4. Ensure You're Using the Correct Terminal
Make sure you're running the MinGW64 Terminal (not the regular MSYS Terminal) when compiling. This terminal automatically sets up the correct environment variables for the 64-bit MinGW toolchain, so gfortran can find your installed libraries without extra path configuration.
If you still run into errors, share the exact error message you're getting, and we can narrow it down further!
内容的提问来源于stack exchange,提问作者Kai

