[Biopython-dev] [BioPython] Compiling Bio.PDB.mmCIF.MMCIFlex on Windows

Peter biopython-dev at maubp.freeserve.co.uk
Wed Feb 15 11:39:52 EST 2006


Thomas Hamelryck wrote:
 > If the mmCIF module causes problems it can just be commented out.

I'm beginning to think that might be best (certainly on Windows, as it 
doesn't seem to work "out of the box" using MSVC or cygwin gcc as the 
compiler).

I have just been trying to work out why Bio.PDB.mmCIF.MMCIFlex won't 
compile on Windows with MSVC 6.0

First of all, running "setup.py build" doesn't seem to call flex.  For 
example, it doesn't regenerate lex.yy.c if I delete it before hand.

The version of Bio/PDB/mmCIF/lex.yy.c currently in CVS has the following 
as line 12:

#include <unistd.h>

This is unconditional, and won't work with MSVC because the header does 
not exist.

If I change to the relevant directory, and run "flex mmcif.lex" using 
the cygwin version of flex version 2.5.4 then the lex.yy.c file is 
recreated, and in addition to some lines moving about, this include 
statement becomes:

#ifndef _WIN32
#include <unistd.h>
#endif

This still will not compile because it has not defined exit, malloc, 
realloc and free:

lex.yy.c(1505) : warning C4013: 'exit' undefined; assuming extern 
returning int
lex.yy.c(1568) : warning C4013: 'malloc' undefined; assuming extern 
returning int
lex.yy.c(1586) : warning C4013: 'realloc' undefined; assuming extern 
returning int
lex.yy.c(1596) : warning C4013: 'free' undefined; assuming extern 
returning int

If instead of using the cygwin version of flex, I use the gnuwin32 port, 
which also claims to be flex version 2.5.4 then the lex.yy.c is slightly 
different again - it has NO conditional statements checking for win32.

http://gnuwin32.sourceforge.net/packages/flex.htm

I think the include lines should be something like:

#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

After messing about with lex.yy.c include statements, I can get MSVC to 
compile lex.yy.obj (with warnings) as shown here:

C:\Program Files\Microsoft Visual Studio\VC98\BIN\cl.exe /c /nologo /Ox 
/MD /W3
/GX /DNDEBUG -IBio -Ic:\python23\include -Ic:\python23\PC 
/TcBio/PDB/mmCIF/MMCIF
lexmodule.c /Fobuild\temp.win32-2.3\Release\Bio/PDB/mmCIF/MMCIFlexmodule.obj
MMCIFlexmodule.c
Bio/PDB/mmCIF/MMCIFlexmodule.c(16) : warning C4013: 'mmcif_set_file' 
undefined;
assuming extern returning int
Bio/PDB/mmCIF/MMCIFlexmodule.c(44) : warning C4013: 'mmcif_get_token' 
undefined;
  assuming extern returning int
C:\Program Files\Microsoft Visual Studio\VC98\BIN\cl.exe /c /nologo /Ox 
/MD /W3
/GX /DNDEBUG -IBio -Ic:\python23\include -Ic:\python23\PC 
/TcBio/PDB/mmCIF/lex.y
y.c /Fobuild\temp.win32-2.3\Release\Bio/PDB/mmCIF/lex.yy.obj
lex.yy.c


But then it fails at the link stage:


C:\Program Files\Microsoft Visual Studio\VC98\BIN\link.exe /DLL /nologo 
/INCREMENTAL:NO /LIBPATH:c:\python23\libs /LIBPATH:c:\python23\PCBuild 
fl.lib /EXPORT:initMMCIFlex 
build\temp.win32-2.3\Release\Bio/PDB/mmCIF/lex.yy.obj build\temp.win3
2-2.3\Release\Bio/PDB/mmCIF/MMCIFlexmodule.obj 
/OUT:build\lib.win32-2.3\Bio\PDB\mmCIF\MMCIFlex.pyd 
/IMPLIB:build\temp.win32-2.3\Release\Bio/PDB/mmCIF\MMCIFlex.lib
LINK : fatal error LNK1181: cannot open input file "fl.lib"
error: command '"C:\Program Files\Microsoft Visual 
Studio\VC98\BIN\link.exe"' failed with exit status 1181


This looks similar to the linking problem Michiel sees on Windows using 
cygwin gcc as the compiler:

http://www.biopython.org/pipermail/biopython/2006-February/002923.html

Is the problem that the linker can't find the flex library?

I assume it needs either the wingnu32 flex file installed by default here:

C:\Program Files\GnuWin32\lib\libfl.a

Or, if using the cygwin flex, here:

C:\cygwin\lib\libfl.a

Peter




More information about the Biopython-dev mailing list