So what to do?
Below are the steps that I find work reasonably well (hopefully documented in a way that will allow other people to do the same for whatever library they are working with).
Note - I assume the following:
- The code as provided will compile with Visual C (if Visual C cannot compile it - then your job is way harder!)
- No extra tools (autoconf, etc) are required
So the steps are:
- Ensure directory with Python.h is in the %include% directories (menu item: Tools -> Options, Projects and Solutions -> VC++ Directories, Show directories for -> Include Files)
- Ensure directory with Python.lib is in the %lib% directories (as as steps for Include files - just select Library Files instead at the end)
- In Visual Studio 2008 (for Python 2.6) select menu item File -> New -> Project From Existing Code...
- Select the directory with the downloaded code as the Project File Location
- Give the project a name (generally a good idea to give it the name of the Python module - i.e. in my example "Stemmer" )
- Ensure that the Release build is selected (if using the toolbar) because generally on windows you will not have the debug library: python_d.lib.
- Modify the project properties:
Set General -> Configuration Type to "Dynamic Library (.dll)"
Set file extenstion for Linker -> General -> Output File to ".pyd" - Try and compile - here are some of the common problems and possible solutions:
- "multiply defined symbols"
libstemmer_utf8.obj : error LNK2005: _sb_stemmer_length already defined in libstemmer.obj
...
Release\Stemmer.pyd : fatal error LNK1169: one or more multiply defined symbols found
The reason for this is that a symbol is defined in 2 source files, for PyStemmer this was because there is both libstemmer_utf8.c and libstemmer.c in the codebase which define the same symbols. The fix was to remove one from the project
- "Cannot open include file"
.\src\Stemmer.c(30) : fatal error C1083: Cannot open include file: 'libstemmer.h': No such file or directory
This is a simple fix - find where the include file is and add it to the include path Project Properties dialog, C/C++ -> General -> Additional Include Directories
- "multiply defined symbols"
This is as much a reminder for me - but if this helps you great :)
You know, that archive does contain a `setup.py` that is the standard way of installing projects within Python.
ReplyDeleteJust do `python setup.py install` and you are done.
Yes - I do know it contained setup.py and I ran it - and got
ReplyDelete.....
build\lib.win32-2.6\Stemmer.pyd : fatal error LNK1120: 49 unresolved externals
error: command '"c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' failed with exit status 1120
That was why I compiled it outside of distutils. I am not an expert on distutils and it was easier (for me) to get it running with my instructions above than figuring out how either the package or my environment was broken.
Hello Mark
ReplyDeleteI am trying to automate an App(built in VC++) that uses Rogue Wave Stingray for displaying grids. The automation tool our management would like QA team to use for this purpose is pywinauto since handling Windows controls is pretty easy :). However we are totally stuck with recognizing and performing an operation on StingRay objects in python.
I googled sufficiently and did not get any good leads.
So here I am. Any pointers/guide in this topic would be highly appreciated and would be of great help.
Thanks in advance for your time!
Thanks
Deepa Mariapillai
I am reachable in deepa.mkm@gmail.com
Hello Mark
ReplyDeleteI do want to reach you for your guidance in using PyWinAuto for recognizing Rouge Wave Sting Ray controls. Any guidance would be a great help and much appreciated. Am reachable at deepa.mkm@gmail.com. Hope to hear from you.
Thanks
Deepa Mariapillai
http://in.linkedin.com/in/deepamariapillai
Thanks a lot Mark, this post helped me a lot. I also had trouble installing the Stemmer on Windows. With your help it was easy as cake !
ReplyDelete