How to use CLAPACK and ATLAS on Cygwin

by Munehiro Nakazato

RedPin Downloading CLAPACK and ATLAS

RedPin Compiling ATLAS

From ATLAS/ directory, simply type

$ make config

You can answer YES to most questions. Then, type

$ make 

Copy library files into /usr/local/lib

RedPin Compiling CLAPACK

Unarchive and modify as follows,

$ tar xzfv clapack.tgz
$ cp INSTALL/ ./


BLASLIB = ../../libcblaswr.a -L/usr/local/lib -lcblas -latlas

This ensures CLAPACK uses ATLAS. See README.install for further instruction.

Then compile,

$ make f2clib
$ make cblaswrap
$ cd SRC; make
$ cd TESTING; make

After CLAPACK is compiled successfully, copy the files into /usr/local/. Don't forget to copy files under CLAPACK/F2CLIB/ (libF77.a, libI77.a and f2c.h) as well.

Now, you should have the following files in /usr/local/

cblas.h  clapack.h  f2c.h

lapack_CYGWIN.a  libI77.a    libcblas.a    libf77blas.a  libtstatlas.a
libF77.a         libatlas.a  libcblaswr.a  liblapack.a   tmglib_CYGWIN.a

RedPin Compiling Your C/C++ Programs with ATLAS and CLAPACK

Finally, you can compile your CBLAS/CLAPACK program as follows:

$ gcc -mno-cygwin -I/usr/local/include -O3 -o myfile myfile.c \
/usr/local/lapack_CYGWIN.a \
-L/usr/local/lib -lcblaswr -lcblas -latlas -lg2c \

RedPin Making DLL for Java JNI with ATLAS and CLAPACK

Following the convention of Java Tutorial, assume we are compiling a native code named HelloWorldImp.c

$ gcc -mno-cygwin -I/usr/local/include \
-I$(JAVAHOME)/include -I$(JAVAHOME)/include/win32 \
-Wl,--add-stdcall-alias -shared \
/usr/local/lapack_CYGWIN.a \
-L/usr/local/lib -lcblaswr -lcblas -latlas -lg2c \
HelloWorldImp.c -o hello.dll 

$(JAVAHOME) is the location of your JDK, for example /cygdrive/c/jdk1.4.1_01.

RedPin NOTE: Creating a Cygwin-independent Binary

When you build in the manner above, the created executables or DLLs requiere cygwin1.dll to run.

If you want to create Cygwin-independent binaries, you need to compile them with MinGW ( Installing MinGW is very easy.

Then, change your PATH so that MinGW binaries (e.g. /cygdrive/c/MinGW/bin) appear before the Cygwin binaries such as /usr/bin. You can do it in /etc/profile, .profile or .bashrc. You don't have to change anything else. This will create Cygwin-independent binaries that require neither Cygwin nor MinGW at runtime.

UI Logo

Copyright © 2003 Munehiro Nakazato. All rights reserved.