编译ARPACK时大量源文件未编译,求编译器选择建议
Hey there! Let's tackle your two key questions—compiler selection for ARPACK, and fixing the "massive source files not compiled" issue—since you're working with VS2017, Intel Fortran (ifort), and MKL on 64-bit Windows 10.
1. Should I use gfortran or ifort to compile ARPACK? Are there differences?
First off, both compilers work for ARPACK, but there are practical differences tied to your existing setup:
- Intel Fortran (ifort) + MKL: This is your best bet right now, given you already have VS2017, ifort, and MKL set up.
- ARPACK relies on BLAS/LAPACK, and MKL provides highly optimized implementations of these libraries—so linking ARPACK with MKL will give you great performance.
- ifort has excellent compatibility with older Fortran standards (ARPACK has significant Fortran 77 code) and integrates seamlessly with your Visual Studio workflow. You can easily add the compiled ARPACK library to your Fortran 90 projects in VS.
- gfortran (via MSYS2/MinGW-w64): This is a solid open-source alternative, but it’s better suited if you want to stick to a fully free toolchain.
- MSYS2 even has pre-built ARPACK packages you can install directly with
pacman -S mingw-w64-x86_64-arpack—skipping the hassle of manual compilation entirely. - The catch: Mixing gfortran-compiled libraries with ifort projects can lead to linking errors (due to different compiler ABIs). If you go this route, you’ll likely need to compile your entire Fortran 90 codebase with gfortran too.
- MSYS2 even has pre-built ARPACK packages you can install directly with
In terms of core functionality? No difference—ARPACK’s eigenvalue solvers will behave the same regardless of which compiler you use. The choice comes down to your existing toolchain and whether you prioritize seamless VS integration or open-source freedom.
2. Fixing "massive source files not compiled" during ARPACK build
Most of the time, this issue stems from a misconfigured build script (makefile) that doesn’t match your compiler or platform. Here’s how to troubleshoot:
Adapt the ARPACK makefile for ifort:
The default ARPACK makefile is often set up for Unix compilers or gfortran. Open the makefile and adjust these key settings:FC = ifort FFLAGS = -O2 -warn all -DMKL_ILP64 # Add MKL defines if using MKL BLAS_LIBS = -L"$(MKLROOT)/lib/intel64" -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm LAPACK_LIBS = $(BLAS_LIBS) # MKL includes LAPACK, so reuse BLAS linksMake sure
MKLROOTis set correctly (it should be automatically set in the VS Developer Command Prompt).Verify 64-bit platform alignment:
Ensure the makefile is targeting 64-bit Windows. Look for flags like-m64(for gfortran) or confirm that ifort is set to compile 64-bit code (in VS, this is under Project Properties > Platform > x64).Use CMake for simpler configuration:
If manual makefile edits feel tedious, use CMake to generate a VS solution or makefile tailored to your environment:- Create a build directory inside the ARPACK source folder.
- Run
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_Fortran_COMPILER=ifort -DARPACK_USE_MKL=ONin the build directory. - Open the generated
.slnfile in VS, or runcmake --build .to compile directly.
Check build output for specific errors:
When you runmakeor build in VS, look for specific error messages (e.g., "file not found", "undefined reference"). Common issues include missing source file paths, incorrect include directories, or missing BLAS/LAPACK links. Fix those specific issues first—they’re usually the root cause of uncompiled files.
内容的提问来源于stack exchange,提问作者Kai

