posted Jan 19, 2015, 11:33 PM by Teng-Yok Lee
[
updated Jan 21, 2015, 7:27 AM
]
This is a revision of Jernej Barbic's steps to build ARPACK for Visual Studio. The original steps are in the URL below: http://www-bcf.usc.edu/~jbarbic/arpack.html I met issues when executing step 3 so I decide to put my modified procedure here. For 32-bit, you can try both gfortran or g77. For 64-bit, only gfortran can work. My recommendation is to use the MinGW64 in CYGWIN64.
Use gfortran (Win32)- Modify ARmake.inc in the source code root. I extracted the source code of ARPACK to D:\src\ARPACK. Also I cannot find f77 in the latest MinGW so I used gfortran instead. Thus the following variables should be changed accordingly:
home = /d/src/ARPACK
PLAT = win32
FC = gfortran
FFLAGS = -O
- Open a MSYS window and:
cd /d/src/ARPACK.
- Compile the .f to .o:
make
lib
- Wrap the *.o to .dll. I need to add the library gfortran:
dllwrap --export-all-symbols
BLAS/*.o LAPACK/*.o SRC/*.o UTIL/*.o -lg2c - lgfortran --output-def arpack_win32.def -o arpack_win32.dll
- Open a Visual Studio Command Prompt and:
cd d:\src\ARPACK
- Generate the library:
lib.exe
/machine:i386 /def:arpack_win32.def
Use g77 (Win32)- Modify ARmake.inc in the source code root. I extracted the
source code of ARPACK to D:\src\ARPACK. Also I cannot find f77 in the
latest MinGW so I used gfortran instead. Thus the following variables
should be changed accordingly:
home = /d/src/ARPACK
PLAT = win32
FC = g77
FFLAGS = -O
- Open a MSYS window and:
cd /d/src/ARPACK.
- Compile the .f to .o:
make
lib
- Wrap the *.o to .dll.
dllwrap --export-all-symbols
BLAS/*.o LAPACK/*.o SRC/*.o UTIL/*.o -lg2c --output-def arpack_win32.def -o arpack_win32.dll
- Open a Visual Studio Command Prompt and:
cd d:\src\ARPACK
- Generate the library:
lib.exe
/machine:i386 /def:arpack_win32.def
Use gfortran (Win 64) in MSYS
Before the procedure, install MinGW 64. In my case, it is installed to C:\Program Files (x86)\mingw-w64, and gfortran.exe is in C:\Program Files (x86)\mingw-w64\i686-4.9.2-posix-dwarf-rt_v3-rev1\mingw32\bin. - Modify ARmake.inc in the source code root. I extracted the
source code of ARPACK to D:\src\ARPACK. Also I cannot find f77 in the
latest MinGW so I used gfortran instead. Thus the following variables
should be changed accordingly:
home = /d/src/ARPACK
PLAT = x64
FC = /c/Program\ Files\ \(x86\)/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/bin/gfortran.exe
FFLAGS = -O
RANLIB = /c/Program\ Files\ \(x86\)/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/bin/ranlib.exe
- Open a MSYS window and:
cd /d/src/ARPACK
- Extend PATH:
export PATH=$PATH:/c/Program\
Files\ \(x86\)/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/opt/bin
- Change UTIL/second. Remove the sentence: EXTERNAL ETIME.
- Compile the .f to .o:
make
lib
- Wrap the *.o to .dll:
/c/Program\
Files\ \(x86\)/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/bin/ dllwrap.exe --export-all-symbols
BLAS/*.o LAPACK/*.o SRC/*.o UTIL/*.o - lgfortran --output-def arpack_x64.def -o arpack_x64.dll
- Open a Visual Studio (64-bit) Command Prompt and:
cd d:\src\ARPACK
- Generate the library:
lib.exe
/machine:X64 /def:arpack_x64.def
Use gfortran (Win 64) in cygwin
Later I found later MinGW is also available in CYGWIN, which make the commands shorter. Before the procedure, install mingw64-x86_64-gcc in CYGWIN 64. - Modify ARmake.inc in the source code root. I extracted the
source code of ARPACK to D:\src\ARPACK. Also I cannot find f77 in the
latest MinGW so I used gfortran instead. Thus the following variables
should be changed accordingly:
home = /cygdrive/d/src/ARPACK
PLAT = x64
FC = /usr/bin/x86_64-w64-mingw32-gfortran.exe
FFLAGS = -O
RANLIB = /usr/bin/x86_64-w64-mingw32-ranlib.exe
- Open a MSYS window and:
cd / cygdrive/ d/src/ARPACK
- Change UTIL/second. Remove the sentence: EXTERNAL ETIME.
- Compile the .f to .o:
make
lib
- Wrap the *.o to .dll:
/usr/bin/x86_64-w64-mingw32-dllwrap.exe
--export-all-symbols BLAS/*.o LAPACK/*.o SRC/*.o UTIL/*.o -lm -lgfortran
--output-def arpack_x64.def -o arpack_x64.dll
- Open a Visual Studio (64-bit) Command Prompt and:
cd d:\src\ARPACK
- Generate the library:
lib.exe
/machine:X64 /def:arpack_x64.def
Link the libAfter building .lib and .dll, adding the directories of related dll. to your path. For CYGWIN, the path is C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin For MinGW, it should be the path to the 64-bit. If the .dll does not match to the linked library, it might show error The application was unable to start correctly (0xc000007b). I saw it when my system had both 32-bit and 64-bit versions of MinGW. After I uninstalled both and just kept CYGWIN 64, the problem was solved. References- External issue of etime: https://gcc.gnu.org/ml/fortran/2007-03/msg00305.html
- Use CYGWIN and MinGW64 to build Visual Studio libraries: https://github.com/arrayfire/arrayfire/wiki/CBLAS-for-Windows
- Cannot start my application: http://stackoverflow.com/questions/25124182/mingw-gcc-the-application-was-unable-to-start-correctly-0xc000007b
|
|