slycot - BLAS/LAPACK installtion problem

1,476 views
Skip to first unread message

DMT

unread,
Apr 23, 2012, 8:56:46 AM4/23/12
to python(x,y)
Hi,

I would like to use the modified version of the Python Control Systems
Library (python-control), "control-0.5b", that has been modified by
Roberto Bucher "http://www.dti.supsi.ch/~bucher/python/index.html" to
allow for MIMO systems.

The run-up to the problem:
1.In order to use the modified control package, I need SLYCOT, which I
can't seem to get to install. Slycot is dependent on BLAS/LAPACK. I
have followed the instructions on "http://icl.cs.utk.edu/lapack-for-
windows/lapack/" and built my own libraries for BLAS/LAPACK using
MingW32 in Windows 7.

2.I have copied the freshly build libraries, liblapack.lib and
libblas.lib, to c:\Python27\libs and c:\MinGW32-xy\mingw32\lib

3.I have aslo copied the DLL files, liblapack.dll and libblas.dll, to
c:\Python27\DLLs.

4. I have additionally added c:\Python27\DLLs, c:\Python27\libs and c:
\MinGW32-xy\BIN to the system path and restated the Win7 to make sure
they are included.

5. I checked whether lapack was linked in Python by using the
following test:

import numpy.distutils.system_info as sysinfo
sysinfo.get_info('lapack')

which gave a positive indication that python sees the lapack library:
{'language': 'f77',
'libraries': ['lapack'],
'library_dirs': ['C:\\Python27\\libs']}.

6. From the slycot folder I executed in the command window: "python
setup.py build --compiler=mingw32"
*Note: Using the "build --compiler=mingw32" instead of the "install"
suffix, fixes the problem of "cannot find vccvarsall.bat" by
indicating that mingw32 should be used.

7. After running for a while the following error jumps up:
.......
build\temp.win32-2.7\Release\slycot\src\TD03AY.o:TD03AY.f:(.text
+0x537): undefined reference to `dcopy_'
build\temp.win32-2.7\Release\slycot\src\TD03AY.o:TD03AY.f:(.text
+0x55f): undefined reference to `daxpy_'
........
build\temp.win32-2.7\Release\slycot\src\TG01WD.o:TG01WD.f:(.text
+0xa9c): undefined reference to `dgemm_'
collect2: ld returned 1 exit status
error: Command "C:\MinGW32-xy\bin\gfortran.exe -Wall -Wall -shared
build\temp.wi
n32-2.7\Release\build\src.win32-2.7\slycot\src\_wrappermodule.o build
\temp.win32
-2.7\Release\build\src.win32-2.7\fortranobject.o build
\temp.win32-2.7\Release\sl
........
.o build\temp.win32-2.7\Release\slycot\src\UD01ND.o build
\temp.win32-2.7\Release
\slycot\src\UE01MD.o -Lc:\mingw32-xy\lib\gcc\mingw32\4.5.2 -LC:
\Python27\libs -L
C:\Python27\PCbuild -llapack -lpython27 -lgfortran -o build
\lib.win32-2.7\slycot
\_wrapper.pyd" failed with exit status 1


Questions:
Q1. Is this a problem with the slycot installation script under
Windows or am I missing some libraries or paths somewhere?

Q1a. From other forums that discussed similar errors, "http://
software.intel.com/en-us/forums/showthread.php?t=54946" advice was
given that "You should link *.o before the libraries, so that all
unreferenced symbols are seen before libraries are searched.". Problem
with the script or include paths or missing libs?

Q1b. However, from discussion forum "http://icl.cs.utk.edu/lapack-
forum/viewtopic.php?f=2&t=1564", it was suggested that the
installation of slycot runs fine under linux. Which points back to my
initial question Q1.

DMT

unread,
May 9, 2012, 6:53:46 AM5/9/12
to python(x,y)
I managed to find a solution. Here are the instructions I followed:

BUILDING AND INSTALLING BLAS/LAPACK:
<http://icl.cs.utk.edu/lapack-for-windows/lapack/index.html#build>
1. Download the lapack.tgz from the netlib website and unzip.
2. Download CMAKE and install it on your machine.
3. See that the pythonxy setup installed MinGW32 on your machine.
4. Put the GNU runtime directory in your PATH, for me I added Add C:
\MinGW32-xy\bin in my PATH (right click on your computer icon, go to
properties, advanced system settings, Environment Variables, look for
the PATH variable and put 'C:\MinGW32-xy\bin;' in front of its current
value)
5. Open CMAKE
Point to your lapack-3.4.1 folder as the source code folder
Point to a new folder where you want the build to be (not the same
is better)
Click configure, check the install path if you want to have the
libraries and includes in a particular location.
Choose MinGW Makefiles.
Click "Specify native compilers" and indicate the path to the Mingw
compilers. On my machine, it is "C:\MinGW32-xy\bin\gfortran.exe"
Set the 'BUILD_SHARED_LIBS' option to ON.
Click again configure until everything becomes white
Click generate, that will create the mingw build.
Close CMAKE
6. Open a cmd prompt (Click Run.. then enter cmd)
7. Go to your build folder using the cd command
8. Type C:\MinGW32-xy\bin\mingw32-make.exe
9. Type C:\MinGW32-xy\bin\mingw32-make.exe test if you want to run
LAPACK testings to make sure everything is ok
10. Your libs are in the lib folder, the dlls are in the bin folder.
11. Copy DLL files from the bin folder to:
C:\Python27\DLLs
12. Add "C:\Python27\DLLs" to the windows system path
12. Copy the xxx.dll.a files from the libs folder to:
C:\MinGW32-xy\lib\gcc\mingw32\4.5.2 ('4.5.2' may differ depending
on your version that's installed)

BUILDING AND INSTALLING SLYCOT:
<https://github.com/avventi/Slycot>
13. In unpacked Slycot folder, find and open setup.py with a text
editor. Find and change the line
from:
libraries = ['lapack']
to:
libraries = ['lapack', 'blas']
(this solved the linking problem when compiling)
14. In the command prompt, navigate to the unpacked slycot folder and
run:
python setup.py build --compiler=mingw32

14b. after the build is complete, run:
python setup.py install


INSTALLING control-0.5b:
<http://sourceforge.net/projects/python-control/files/>
15. Unpack control-0.5b.tag.gz
16. Open the command prompt and navigate to unpacked folder
17. In the command prompt run:
python setup.py install

And that should do the trick.

David Nash

unread,
Oct 6, 2012, 2:35:40 PM10/6/12
to pyth...@googlegroups.com, malesto...@gmail.com
I had broken the scipy installation, so I did a fresh install and it worked. The pythonxy installer seems to have associated my old mysys installation with the new pythonxy version of mingw, or everything was resolved in a build script, thanks for the help

Tony Olivo

unread,
Aug 14, 2013, 3:27:50 PM8/14/13
to pyth...@googlegroups.com, malesto...@gmail.com
I know this is a bit of an old thread, but since it turns up when you google "slycot windows" I thought it appropriate to post here. I didn't have any luck with these instructions (I was trying to install Slycot to use python-control), but reinstalled my entire Python distribution with packages from Christoph Gohlke's wonderful pythonlibs page (http://www.lfd.uci.edu/~gohlke/pythonlibs/), including a pre-built Slycot package that worked for me with no additional configuration. http://www.lfd.uci.edu/~gohlke/pythonlibs/#slycot

Andrei Popov

unread,
Jan 15, 2015, 5:49:43 PM1/15/15
to pyth...@googlegroups.com, malesto...@gmail.com
I was trying to install slycot/lapack/blass on Win 7 64 but I couldn't finish compiling from sorce code for various reasons.
So finnaly this is what I found to be the best solution for me without compiling any source code:

grab BLAS and LAPACK libraries from:

http://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.4.1/Dynamic-MINGW/Win32/

* install dll files in C:\Python27\DLLs
* install lib files in C:\Python27\libs

Slycot 0.1.0 from:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#slycot

Reply all
Reply to author
Forward
0 new messages