[MERGE] Fast _walkdirs for win32
Alexander Belchenko
bialix at ukr.net
Thu Jul 17 13:58:51 BST 2008
Alexander Belchenko пишет:
[...]
> 2) But anyway it failed because linker cannot find Win32 API functions:
>
> C:\work\Bazaar\mydev.packs\win32_find_files>make
> _walkdirs_win32.obj : error LNK2019: unresolved external symbol
> __imp__FindClose referenced in function ___pyx_f_15_walkdirs_win
> 32_11Win32Finder__get_files_in
> _walkdirs_win32.obj : error LNK2019: unresolved external symbol
> __imp__FindNextFileW referenced in function ___pyx_f_15_walkdirs
> _win32_11Win32Finder__get_files_in
> _walkdirs_win32.obj : error LNK2019: unresolved external symbol
> __imp__GetLastError referenced in function ___pyx_f_15_walkdirs_
> win32_11Win32Finder__get_files_in
> _walkdirs_win32.obj : error LNK2019: unresolved external symbol
> __imp__FindFirstFileW referenced in function ___pyx_f_15_walkdir
> s_win32_11Win32Finder__get_files_in
> bzrlib\_walkdirs_win32.pyd : fatal error LNK1120: 4 unresolved externals
> Building of "bzrlib._walkdirs_win32" extension failed, will use the
> Python version instead
>
>
> I found that if I compile _walkdirs_win32.c with custom setup.py
> (without involving Pyrex at all)
> I get the same error. When I looked at the generated C code I saw this
> definition:
>
> #ifndef WIN32
> #define __stdcall
> #define __cdecl
> #endif
>
> If I manually add
>
> #define WIN32_LEAN_AND_MEAN
> #include <windows.h>
>
> before mentioned lines *then* module compiled successfully without any
> warning or error.
> I don't know is it Pyrex bug or not.
More info on this: I found that if I add
define_macros=[('WIN32', None)]
in my custom setup.py
then I can build C-extension successfully. But with Pyrex this does not work,
probably Pyrex does not pass this variable to distutils build_ext.
Here is my simple custom setup.py:
from distutils.core import setup, Extension
setup(name = "_walkdirs_win32",
ext_modules = [Extension('_walkdirs_win32', ['_walkdirs_win32.c'],
define_macros=[('WIN32', None)])
]
)
More information about the bazaar
mailing list