[lxml-dev] Building dynamically-linked lxml on windows using mingw32
Hello, I've successfully used ming32 to build lxml (dynamically linked). I was unable to get the static linking to work, because I was unable to get the VC++ 2003 Toolkit compiler and trying static linking with gcc gives lots of errors. Step 1: Download and install Mingw from http://mingw.org. Step 2: Start a command window and set the path to include MingW eg. set path=%path%;C:\mingw\bin Step 3: Download the win32 libs from ftp://xmlsoft.org/libxml2/win32. You will need iconv-1.9.1.win32.zip libxml2-2.6.23.win32.zip libxslt-1.1.15.win32.zip zlib-1.2.3.win32.zip Step 4: Follow the instructions in doc/build.txt for extraction, but use the following setupStaticBuild function instead of the one mentioned: def setupStaticBuild(): "See doc/build.txt to make this work." cflags = [ "-I..\\libxml2-2.6.23.win32\\include", "-I..\\libxslt-1.1.15.win32\\include", "-I..\\zlib-1.2.3.win32\\include", "-I..\\iconv-1.9.1.win32\\include" ] xslt_libs = [ "..\\libxml2-2.6.23.win32\\bin\\libxml2.dll", "..\\libxslt-1.1.15.win32\\bin\\libxslt.dll", "..\\libxslt-1.1.15.win32\\bin\\libexslt.dll", "..\\iconv-1.9.1.win32\\bin\\iconv.dll", "..\\zlib-1.2.3.win32\\lib\\zlib.lib" ] result = (cflags, xslt_libs) return result Yes, We ARE linking to DLLs directly as the export libraries are incomplete. 5. Copy the 4 DLLs mentioned above to the src/lxml folder. Also, add this line towards the end of the file, just below the "packages = ['lxml']," line: package_data={'': ['*.dll']}, 6. To build the extension, use the following command: python setup.py build --c=mingw32 --static bdist_wininst You should have an installer which uses lxml dynamically linked to the above DLLs. The installer size is around 1344kB, which is almost the same size you get via static linking. (as a comparison, lxml-1.0.2.win32-static-py2.4.exe is around 1266kB). Hope this helps, Ashish
Hi Ashish, Ashish Kulkarni wrote:
I've successfully used ming32 to build lxml (dynamically linked).
Thanks for sharing your experience. It's always helpful to have this kind of info archived on the list so that others can find it.
I was unable to get the static linking to work, because I was unable to get the VC++ 2003 Toolkit compiler and trying static linking with gcc gives lots of errors.
That would be the expected behaviour, I guess. Even using newer MS compilers with the VC-2003 compiled Python interpreter does not work, from what I've heard. That's been discussed on python-dev for some other extensions a while ago. Don't remember the result, though... Stefan
participants (2)
-
Ashish Kulkarni
-
Stefan Behnel