How to build Python extensions with LCC-...
Note: All the text files used here are included at the end of this blog entry.
Note2: It is recommended that you used either Visual C or GCC (MingW32 on Windows) to build your C Python modules. If you like LCC-Win32 as I do, and are interested in building your own Python modules with it, then keep on reading!
Before startingYou need to have Python installed on your Windows, http://www.python.org/
It is also recommended to have the latest version of LCC-Win32, available from http://www.q-software-solutions.de/downloaders/get_name
I also recommend that you install both Python and LCC to paths that do not have spaces in their names (for example, not under Prorgam Files).
If you want to follow up these steps as I have made them, create a new folder called
dev under Python's installation path. All the new files mentioned hereafter are to be placed in this folder.
Before the first buildThe library files included with Python are designed for Visual studio and are not directly usable. You need to first convert the Python25.lib (or whichever version your Python is) into LCC compatible format. You can do the conversion using Wedit program included with LCC-Win32, however, I have written a simple LIBCONV batch file that can be used from command line to convert any such library file to LCC format, find LIBCONV.BAT at the end of this post.
Open cmd.exe and navigate into the dev folder you created, and type in this:
Code:
libconv ..\libs\python25.lib python25.lib
You should end up having two new files in your dev folder, python25.lib and python25.lib.exp. You can copy the new python25.lib inside the lib folder of your lcc installation if you so want. The exp file can be deleted, if you don't want it (it was only used to create the lib file itself).
Now that you have a compatible library file, you can actually compile and link the C source file to work inside Python.
Building Python extensionThe included batch files require that your C source file has the form of
namemodule.c, where
name is the name of the...