INSTALLING UMFPACK and GOTO_BLAS for VISUALC++ on WINDOWS XP Date: 14-Jan-2009 This document describes my successful attempt to install UMFPACK and GOTO_BLAS for use with VISUALC++ (MSVC) under WINDOWS XP. To do this I use Cygwin trhgoutout. The method is certainly not optimal, but it did work. Hopefully persons with more expertise with the various tools will make suggestions and improvements. In particular, it would be nice to get dynamic link versions of the libraries. My Hardware: Pentium 4 CPU 3.20 GHz 1.00 GB RAM My Software components: Microsoft Windows XP Version 2002 Service Pack 3 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86 CYGWIN_NT-5.1 xxx 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) GotoBLAS2-1.09p1 UMFPACK Version 5.4.0 AMD-2.2.0 My approach is to us Cygwin to build the needed libraries for UMFPACK and GotoBlas and to located the needed XP libraries. With slight adaptations I follow instructions in Evgenii Rudnyi's "Compiling UMFPACK". An alternative approach is described in "Compiling UMFPACK with Microsoft Visual C", but I was not able to make this work so I do not follow that approach here. Launch Cygwin and choose a directory where you want to install UMFPACK. In this document I will call that directory INSTALL_DIR. GotoBLAS2, UMFPACK, and AMD are available for free download from the internet. Get their gzip files and place them in INSTALL_DIR, and unzip them with gunzip. Then untar each file with: tar -xvf This will create directories GotoBLAS2, AMD, UFconfig, and UMFPACK all as subdirectories of INSTALL_DIR. Delete the *.tar files if you want. Begin by compiling the GotoBlas. To do this, "cd" into the GotoBlas directory and edit the file, Makefile.system. Find the line "CC = gcc" and add the word "-mno-cygwin" so the line reads: CC = gcc -mno-cygwin This is necessary to build a library that is compatible with MSVC. It would probably be better to alter the CFLAGS variable, but it seemed to be defined in two places in Makefile.system, and I was not sure which place to change it. Instead I changed CC as per the line above. Next "cd" into the exports subdirectory and edit dllinit.c. Change two lines: gotoblas_init(void); ---> gotoblas_init(); gotoblas_quit(void); ---> gotoblas_quit(); where the arrows separate old and new versions. I am not sure it this change is necessary or even correct. It eliminates a compiler error message, but in the end the dll was never built anyway. So I left the change in dllinit.c, and went on without the dll. Hopefully someone else can do better here. After changing dllinit.c, "cd" back up to the main GotoBlas directory (one level up) and type: make My computer took about 30 minutes to finish. It ended with an error alluded to above, concerning libgoto2.dll. I will ignore this. The file libgoto2.a which just points to libgoto2_prescottp-r1.09p1.a has been successfully created, and this contains the BLAS library. The gotoBLAS is now complete. Next build UMFPACK. Cd up one level to INSTALL_DIR, then cd down into the UFconfig directory. Edit the file, UFconfig.mk. Alter the "CFLAGS =" line: CFLAGS = -03 ---> CFLAGS = -03 -mno-cygwin This is done for the same reason as above. One other line must be changed. Find the line "# Using the Goto BLAS:". Modify the line following it to read: BLAS = -L../../GotoBLAS2 -lgoto2 -lfrtbegin -lg2c $(XERBLA) - lpthread Be sure to remove the leading '#' symbol from the BLAS line. It is no longer a comment! Next "cd" up to INSTALL_DIR, and down into UMFPACK. Type: make It takes a few minutes to build UMFPACK and to test the Demos in the Cygwin Environment. In order to use UMFPACK with MSVC, libraries with *.a file extensions must be renamed to have *.lib extensions. Six libraries are needed: libgoto2.lib (from INSTALL_DIR/GotoBLAS2/libgoto2.a) libumfpack.lib (from INSTALL_DIR/UMFPACK/Lib/libumfpack.a) libamd.lib (from INSTALL_DIR/AMD/Lib/libamd.a) libg2c.lib (from /lib/gcc/i686-pc-mingw32/3.4.4/lib2c.a) libgcc.lib (from /lib/gcc/i686-pc-mingw32/3.4.4/libgcc.a) ADVAPI32.LIB (from "C:\PROGRAM Files\Microsoft Visual Studio \VC98\Lib") I use the following lines of a csh-script to create and load a lib directory under my current directory: rm -rf lib # delete my lib directory mkdir lib # recreate my lib directory setenv INSTALL_DIR /homes/xxx/ohsu # load files into my lib directory from various places cp $INSTALL_DIR/GOTOBLAS2/libgoto2.a lib/libgoto2.lib cp $INSTALL_DIR/UMFPACK/Lib/libumfpack.a lib/libumfpack.lib cp $INSTALL_DIR/AMD/lib/libamd.a lib/libamd.lib cp /lib/gcc/i686-pc-mingw32/3.4.4/libg2c.a lib/libg2c.lib cp /lib/gcc/i686-pc-mingw32/3.4.4/libgcc.a lib/libgcc.lib cp "/cygdrive/c/PROGRAM Files/Microsoft Visual Studio/VC98/Lib/ ADVAPI32.LIB" lib/ADVAPI32.LIB It would be nice to have these as dlls and use dynamic linking, but I am not sure what MSVC requires for this. So currently I link statically. To test that this all works with MSVC while staying in the Cygwin environment, I do the following: 1) Launch a Microsoft "cmd" window by running "cmd" 2) Find the file VCVARS32.BAT, which on my system is in directory c:\PROGRAM Files\Microsoft Visual Studio\VC98\Bin Run the file by simply typing its name at the cmd command-line. VCVARS32.BAT This defines the necessary variables needed for Cyginw to run the "CL" command. CL is the command-line name for the MSVC compiler. 3) Start Cygwin from the cmd window (so it inherits the environment variables) by entering (on the cmd command-line): \cygwin\bin\startxwin.bat (X version of cygwin) or for a non X version of cygwin, enter \cygwin\cygwin.bat If Cygwin is not installed in the \Cygwin directory, adjust the commands accordingly. 4) With Cygwin running, make a subdirectory of INSTALL_DIR. Call it TEST_DIR. Check the CL works by entering "CL" at the Cygwin command-line. Version information about the compiler should be displaced. Create and load a subdirectory of TEST_DIR as described above. If you use the csh script I mentioned as written above, this directory will be created and named "lib". From INSTALL_DIR/UMFPACK/Demo copy into TEST_DIR, the following: umfpack_simple.c umfpack_dl_demo.c umfpack_zi_demo.c umfpack_zl_demo.c Place the following lines in a file named Makefile: INCLUDES = -I../UMFPACK/Include -I../AMD/Include -I../ UFconfig LIBS = lib/libgoto2.lib lib/libumfpack.lib lib/libamd.lib lib/libg2c.lib lib/libgcc.lib all: umfpack_simple umfpack_dl_demo umfpack_zi_demo umfpack_zl_demo umfpack_simple: umfpack_simple.c CL -MD $(INCLUDES) umfpack_simple.c $(LIBS) ADVAPI32.LIB umfpack_dl_demo: umfpack_dl_demo.c CL -MD $(INCLUDES) umfpack_dl_demo.c $(LIBS) ADVAPI32.LIB umfpack_zi_demo: umfpack_zi_demo.c CL -MD $(INCLUDES) umfpack_zi_demo.c $(LIBS) ADVAPI32.LIB umfpack_zl_demo: umfpack_zl_demo.c CL -MD $(INCLUDES) umfpack_zl_demo.c $(LIBS) ADVAPI32.LIB clean: *.obj Edit Makefile to be sure the each line that contains "CL" begins with a TAB. It is a weird quirk of "make" that TABS are significant in this way. Then at the Cygwin command-line type: make This will produce *.exe files. Run them by typing their name at the Cygwin command-line. They all worked for me. 5) Finally, give the libraries in TEST_LIB/lib to whom ever wants to use MSVC and let them build their UMFPACK applications. They just have to link with the libraries in the "lib" file. Also, the order that the link files are specified may be important. The order used in the make file above worked for the UMFPACK test cases.