MinGW (3.4.5) binaries of GNU Scientific Library 1.11 for use with MinGW and Visual C

The binaries for GSL 1.12 are provided in this post: MinGW (3.4.5) binaries of GNU Scientific Library 1.12 for use with MinGW and Visual C++

“The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite”.

GSL is quite Unix centric but one might want to use the library at least with MinGW on Windows. I didn’t find any MinGW binaries of GSL apart from the one provided by the Ascend package or the binaries from GNUWin32 (which is only at version 1.8), but I don’t like graphical installers for libraries and I needed the static library. Therefore I compiled my own library with MSYS (I updated MSYS according to this link) and provide here the tarred binary package, which can also be used with the MinGW compiler without MSYS and with Visual C (import libraries for the shared library are provided).

There are no makefiles for the MinGW compiler but it is possible to compile the GSL in the MSYS development environment. I wrote a little bash script which downloads the GSL source package (with the help of curl), untars the package, compiles the source and assembles the binaries and necessary files for development in a tar.gz package using 7zip. Curl and 7zip need to be in the path or in the same directory as the script. The script will create a gsl_mingw directory where the source package is downloaded to and all compilation steps will take place. The tar.gz package will be created in gsl_mingw/package and copied to the directory where the script was run. Below you can download the binary package of GSL 1.11 for the MinGW 3.4.5 compiler toolset (to be used in MSYS and in native Windows CLI) and the script I wrote to compile GSL in MSYS yourself if you want. I also added the import libraries for Visual C (only for the shared GSL) according GNUWin32 descriptions.

Download: GSL 1.11 Binary for MinGW 3.4.5 (with Visual C import libraries)

The script will create a directory “gsl_mingw” in the same directory where the script is run. Before the scripts starts downloading the GSL package, it shows some informations and waits for user input.


#######################################################################
# This MSYS/bash batch file will download, compile and make a package
# of the GNU scientific library for the MinGW compiler. You need to
# have Msys and MinGW already installed.
#
# You need curl.exe and 7za.exe for this script to work
# correctly:
#   - curl 7.18.0 no SSL download location:
# http://curl.haxx.se/download/curl-7.18.0-win32-nossl-sspi.zip
#   - 7-zip 4.57 command line version:
# http://downloads.sourceforge.net/sevenzip/7za457.zip
#######################################################################

#######################################################################
# determine directories and set variables
# source package will be downloaded to $MAINDIR
# source will be compiled in $BUILDDIR
# binary package will be created in $ROOTDIR
#######################################################################
export GSL_VERSION=1.11
export GSL_URL=ftp://ftp.gnu.org/gnu/gsl/gsl-${GSL_VERSION}.tar.gz
export MINGW_VERSION=`gcc -dumpversion`

export ROOTDIR=`pwd`
export MAINDIR=$ROOTDIR/gsl_mingw
export BUILDDIR=$MAINDIR/gsl-${GSL_VERSION}
export PACKAGEDIR=$MAINDIR/package

#######################################################################
# show user the settings and ask if he wants to continue
#######################################################################
echo
echo ==============================================================
echo == Please check the settings
echo ==============================================================
echo
echo Directories
echo ===========
echo ROOTDIR=$ROOTDIR
echo MAINDIR=$MAINDIR
echo BUILDDIR=$BUILDDIR
echo PACKAGEDIR=$PACKAGEDIR
echo
echo Other
echo =====
echo GSL_URL=$GSL_URL
echo GSL_VERSION=$GSL_VERSION
echo MINGW_VERSION=$MINGW_VERSION
echo

echo "Should the build process be continued? Type y to continue!"
read -n 1 -s
if [ "$REPLY" != "y" ]; then
echo "Shell script stopped ..."
exit -1;
fi

#######################################################################
# create directories
#######################################################################
mkdir $MAINDIR
mkdir $PACKAGEDIR

#######################################################################
# download and unpack gsl source code
#######################################################################
echo +++ Downloading gsl from $GSL_URL +++
curl $GSL_URL -o $MAINDIR/gsl-${GSL_VERSION}.tar.gz
pushd $MAINDIR
tar xzf gsl-${GSL_VERSION}.tar.gz
popd

#######################################################################
# configure and build library
#######################################################################
mkdir $BUILDDIR/buildstatic
pushd $BUILDDIR/buildstatic
../configure --enable-static=yes --enable-shared=no --prefix=$PACKAGEDIR/gsl-${GSL_VERSION}-static
make
make install
popd

mkdir $BUILDDIR/buildshared
pushd $BUILDDIR/buildshared
# CFLAGS=-DGSL_DLL ../configure --enable-static=no --enable-shared=yes  --prefix=$PACKAGEDIR/gsl-${GSL_VERSION}
../configure --enable-static=no --enable-shared=yes --prefix=$PACKAGEDIR/gsl-${GSL_VERSION}-shared
make
make install
popd

#######################################################################
# make package for website
#######################################################################
if [ 1 == 1 ]
then
pushd $PACKAGEDIR
mkdir -p gsl-${GSL_VERSION}/lib-static
mkdir -p gsl-${GSL_VERSION}/lib-shared
mkdir -p gsl-${GSL_VERSION}/bin
mkdir -p gsl-${GSL_VERSION}/include

cp -r gsl-${GSL_VERSION}-static/include/* gsl-${GSL_VERSION}/include
cp -r gsl-${GSL_VERSION}-static/lib/* gsl-${GSL_VERSION}/lib-static
cp -r gsl-${GSL_VERSION}-shared/lib/* gsl-${GSL_VERSION}/lib-shared
cp -r gsl-${GSL_VERSION}-shared/bin/* gsl-${GSL_VERSION}/bin

echo 'This GNU Scientific Library DLL was generated using MingW/Msys.' > gsl-${GSL_VERSION}/README.txt
echo 'configure settings:' >> gsl-${GSL_VERSION}/README.txt
echo '../configure --enable-static=yes --enable-shared=no' >> gsl-${GSL_VERSION}/README.txt
echo '../configure --enable-static=no --enable-shared=yes' >> gsl-${GSL_VERSION}/README.txt
echo '' >> gsl-${GSL_VERSION}/README.txt
echo 'To create Visual C import libraries open a VC command line' >> gsl-${GSL_VERSION}/README.txt
echo 'and in lib-shared run:' >> gsl-${GSL_VERSION}/README.txt
echo 'lib /machine:i386 /def:libgsl-0.def' >> gsl-${GSL_VERSION}/README.txt
echo 'lib /machine:i386 /def:libgslcblas-0.def' >> gsl-${GSL_VERSION}/README.txt
pushd gsl-${GSL_VERSION}/bin
strip gsl-histogram.exe gsl-randist.exe libgsl-0.dll libgslcblas-0.dll
pexports.exe libgsl-0.dll > ../lib-shared/libgsl-0.def
pexports.exe libgslcblas-0.dll > ../lib-shared/libgslcblas-0.def
popd
tar -cf gsl-${GSL_VERSION}_mingw-${MINGW_VERSION}.tar gsl-${GSL_VERSION}
gzip gsl-${GSL_VERSION}_mingw-${MINGW_VERSION}.tar
mv gsl-${GSL_VERSION}_mingw-${MINGW_VERSION}.tar.gz $ROOTDIR
popd
fi

exit 1

1 thought on “MinGW (3.4.5) binaries of GNU Scientific Library 1.11 for use with MinGW and Visual C

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.