Win32 Python 2.0 Readline Module or Is python20.lib missing symbols?

Jason Tishler Jason.Tishler at dothill.com
Tue Nov 21 17:42:32 CET 2000


On Fri, Nov 17, 2000 at 10:52:08AM -0500, Jason Tishler wrote:
> Has anyone been successful building the Readline Module for Win32 Python
> 2.0?

After fiddle around some more, I was able to successfully build the above.
It appears that linking with the native MS linker (i.e., link) as opposed to
the Mingw one (i.e., ld) solved my "missing" symbols problem.

If you would like to build a Win32 Python 2.0 readline module for yourself,
then use the following procedure:

1. Download a pre-built Win32 readline from:

    http://www.textsure.net/~ela/download/readline-Win32.tar.gz

2. Extract readline-Win32.tar.gz to %PathToWin32Readline%.  Note that
%PathToWin32Readline% is installation dependent and needs to be replaced
as appropriate.  For example, I am using H:\src\readline-4.0-Mingw for
%PathToWin32Readline% below.

3. Add a few "missing" __declspec(dllimport) attributes in Modules/readline.c
from the Python 2.0 source distribution:

    ...
    extern __declspec(dllimport) int rl_parse_and_bind(char *);
    extern __declspec(dllimport) int rl_read_init_file(char *);
    extern __declspec(dllimport) int rl_insert_text(char *);
    extern __declspec(dllimport) int rl_bind_key(int, Function *);
    extern __declspec(dllimport) int rl_bind_key_in_map(int, Function *, Keymap);
    extern __declspec(dllimport) int rl_initialize(void);
    ...
    extern __declspec(dllimport) Function *rl_event_hook;
    ...
    extern __declspec(dllimport) int (*PyOS_InputHook)(void);
    extern __declspec(dllimport) char *(*PyOS_ReadlineFunctionPointer)(char *);
    ...

4. Create a new MSVC readline project in the Python 2.0 workspace with the
following key project settings:

    a. choose Win32 Dynamic-Link Library for project type
    b. make it depend on the python20 project
    c. in C/C++, Preprocessor,:
       i. add __READLINE_IMPORT__ to Preprocessor definitions
       ii. add ..\Include,..\PC,%PathToWin32Readline% to Additional include
           directories
    d. in Link, General:
        i. change Output file name from Release/readline.dll to
           Release/readline.pyd
    e. in Link, Input:
       i. add readline.lib to Object/library modules
       ii. add %PathToWin32Readline% to Additional library path
       iii. add /export:initreadline to Project Options

5. Build the "readline - Win32 Release" project.

6. Copy Release\readline.pyd and %PathToWin32Readline%\readline.dll to
%Python20InstallDir%\DLLs, where %Python20InstallDir% is the Win32 Python
2.0 installation directory.

Enjoy,
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation         Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler at dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com




More information about the Python-list mailing list