Need help creating debug lxml for python27 on windows

I am debugging another dll, an imported script that uses lxml. I need to create objectify_d.pyd and etree_d.pyd from an lxml project. I successfully built them, following the assembly instructions here: http://lxml.de/build.html , but using this command:

python setup.py build --debug --static 

I tried just doing:

 python setup.py build --debug 

but it didn’t work.

Building is like success. Objectify_d.pyd and etree_d.pyd are created. Using these files (copying them to c: / python27 / lib / site-packages / lxml /) and running python build debugging, I get the following when trying to import:

 >>> from lxml import objectify Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: DLL load failed: The specified module could not be found. [83669 refs] 

Then I ran python in the debugger and saw that the LoadLibraryEx call was not working (returns NULL). Calling GetLastError () returns 126, which means that it cannot find the dll. The way is right. Therefore, I expect it to not find the dependent DLL. I run this on the machine that built it, so there is no runtime library.

Here is what was printed when I built the dll:

 </c/lxml/lxml-2.3 Trunk> $python setup.py build --debug --static Building lxml version 2.3. Building with Cython 0.15.1. ERROR: 'xslt-config' is not recognized as an internal or external command, operable program or batch file. ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt Building against libxml2/libxslt in one of the following directories: ..\iconv-1.9.2.win32\lib ..\libxml2-2.7.8.win32\lib ..\libxmlsec-1.2.18.win32\lib ..\libxslt-1.1.26.win32\lib ..\zlib-1.2.5\lib c:\python27 running build running build_py running build_ext skipping 'src/lxml\lxml.etree.c' Cython extension (up-to-date) building 'lxml.etree' extension C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Od /MDd /W3 /GS- /Z7 /D_DEBUG -I..\iconv-1.9.2.win32\include -I..\libxml2-2.7.8.win 32\include -I..\libxmlsec-1.2.18.win32\include -I..\libxslt-1.1.26.win32\include -I..\zlib-1.2.5\include -I..\ -IC:\python27\include -IC:\python27\PC /TcC:\lxml \lxml-2.3\src\lxml\lxml.etree.c /Fobuild\temp.win32-2.7\Debug\src/lxml\lxml.etree.obj -w DEBUG cl : Command line warning D9025 : overriding '/W3' with '/w' cl : Command line warning D9024 : unrecognized source file type 'DEBUG', object file assumed cl : Command line warning D9027 : source file 'DEBUG' ignored lxml.etree.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:no /DEBUG /pdb:None /LIBPATH:..\iconv-1.9.2.win32\lib /LIBPATH:..\l ibxml2-2.7.8.win32\lib /LIBPATH:..\libxmlsec-1.2.18.win32\lib /LIBPATH:..\libxslt-1.1.26.win32\lib /LIBPATH:..\zlib-1.2.5\lib /LIBPATH:c:\python27 /LIBPATH:C:\p ython27\libs /LIBPATH:C:\python27\PCbuild libxslt_a.lib libexslt_a.lib libxml2_a.lib iconv_a.lib zlib.lib WS2_32.lib /EXPORT:initetree build\temp.win32-2.7\Debu g\src/lxml\lxml.etree.obj /OUT:build\lib.win32-2.7\lxml\etree_d.pyd /IMPLIB:build\temp.win32-2.7\Debug\src/lxml\etree_d.lib /MANIFESTFILE:build\temp.win32-2.7\Debug\src/lxml\etree_d.pyd.manifest Creating library build\temp.win32-2.7\Debug\src/lxml\etree_d.lib and object build\temp.win32-2.7\Debug\src/lxml\etree_d.exp LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library lxml.etree.obj : warning LNK4049: locally defined symbol _xmlFree imported lxml.etree.obj : warning LNK4049: locally defined symbol _xmlMalloc imported lxml.etree.obj : warning LNK4049: locally defined symbol _xsltDocDefaultLoader imported lxml.etree.obj : warning LNK4049: locally defined symbol _xsltLibxsltVersion imported zlib.lib(adler32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(crc32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(deflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzclose.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzlib.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzread.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzwrite.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(inffast.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(inflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(inftrees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(trees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(zutil.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest build\temp.win32-2.7\Debug\src/lxml\etree_d.pyd.manifest -outputresource:build\lib.win32-2.7\lxml\etree_d.pyd;2 skipping 'src/lxml\lxml.objectify.c' Cython extension (up-to-date) building 'lxml.objectify' extension C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Od /MDd /W3 /GS- /Z7 /D_DEBUG -I..\iconv-1.9.2.win32\include -I..\libxml2-2.7.8.win32\include -I..\libxmlsec-1.2.18.win32\include -I..\libxslt-1.1.26.win32\include -I..\zlib-1.2.5\include -I..\ -IC:\python27\include -IC:\python27\PC /TcC:\lxml\lxml-2.3\src\lxml\lxml.objectify.c /Fobuild\temp.win32-2.7\Debug\src/lxml\lxml.objectify.obj -w DEBUG cl : Command line warning D9025 : overriding '/W3' with '/w' cl : Command line warning D9024 : unrecognized source file type 'DEBUG', object file assumed cl : Command line warning D9027 : source file 'DEBUG' ignored lxml.objectify.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:no /DEBUG /pdb:None /LIBPATH:..\iconv-1.9.2.win32\lib /LIBPATH:..\libxml2-2.7.8.win32\lib /LIBPATH:..\libxmlsec-1.2.18.win32\lib /LIBPATH:..\libxslt-1.1.26.win32\lib /LIBPATH:..\zlib-1.2.5\lib /LIBPATH:c:\python27 /LIBPATH:C:\python27\libs /LIBPATH:C:\python27\PCbuild libxslt_a.lib libexslt_a.lib libxml2_a.lib iconv_a.lib zlib.lib WS2_32.lib /EXPORT:initobjectify build\temp.win32-2.7\Debug\src/lxml\lxml.objectify.obj /OUT:build\lib.win32-2.7\lxml\objectify_d.pyd /IMPLIB:build\temp.win32-2.7\Debug\src/lxml\objectify_d.lib /MANIFESTFILE:build\temp.win32-2.7\Debug\src/lxml\objectify_d.pyd.manifest Creating library build\temp.win32-2.7\Debug\src/lxml\objectify_d.lib and object build\temp.win32-2.7\Debug\src/lxml\objectify_d.exp LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library zlib.lib(adler32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(crc32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(deflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzclose.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzlib.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzread.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(gzwrite.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(inffast.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(inflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(inftrees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(trees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info zlib.lib(zutil.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest build\temp.win32-2.7\Debug\src/lxml\objectify_d.pyd.manifest -outputresource:build\lib.win32-2.7\lxml\objectify_d.pyd;2 

Additional Information:

  • I am using lxml-2.3 code since this is what my application used.
  • I start in a windows 7 window using python27 (32 bit)

I would be happy if someone could provide me with the lxml debug build for windows that work, or point me to an explanation of how to use the python release dlls mixed with the debug dll.

+4
source share
2 answers

Are you building a Cygwin environment and then trying to run on Windows? Try creating on Windows.

+1
source

I have not tried to create a debug version of lxml, but it almost certainly will not work. From what I remember, the installation scripts that came with lxml were made to create a release version.

You can take advantage of this and simply generate debugging symbols (.pdb) for the release version. The procedure is quite complicated, but here is an overview:

  • Install the necessary build tools (Visual Studio, Powershell).
  • Get the source code for lxml dependencies (libxml2, libxslt, iconv, zlib).
  • Create these dependencies and create their debugging symbols.
  • Download the version of lxml that you want to debug (e.g. 3.7.0).
  • Tweak lxml setup.py to point to statically constructed dependencies.
  • Run distutils so that he thinks your specific version of Visual Studio should be used instead of the one used to create your Python interpreter.
  • Create lxml and create its debug symbols.
  • Package of everything in the wheels file.

What is this! :) I suppose it would be more reasonable to associate with a detailed procedure .

Disclaimer: I am the author of the message.

+1
source

Source: https://habr.com/ru/post/1441615/


All Articles