Discussion:
[sword-devel] Sword Python bindings for Windows
R Johnson
2014-10-03 21:32:11 UTC
Permalink
Thanks for the suggestion, Nic. I don't think it would work to use
cygwin, because I have to use the same compiler that Python is built
with on Windows to be able to build the SWIG bindings, but maybe I
should look into building Sword without ICU.

I corresponded with Greg Hellings, and he suggested that maybe I could
"just build Sword with the bundled vc10 solution and drop in a manual
execution of swordswig akin to the one in CMake," which seemed like a
good idea.I tried it, and was able to successfully build Sword and run
SWIG, but now I'm stuck on a setup.py file that needs to be run.

What I'm currently doing is:
1. Building lib/vcppmake/libsword.sln in Visual Studio 2010 (with a few
minor changes to the SLN and VCXPROJ files necessary to make it work
because it is a VC2013 project), which works.
2. From the bindings/swig directory, running the command:
swig.exe -w-451,-402 -shadow -c++ -python -o
../../bindings/swig/python/Sword.cxx -I../../bindings/swig
-I../../include -I../../include/internal/regex
-I../../../icu-sword/include -I../../src/utilfuns/win32
-I../../../curl/include ../../bindings/swig/sword.i
This also works.
3. From the bindings/swig/python directory (where SWIG generated the CXX
file), running the command:
C:\Python34\python.exe setup.py build
I have attached the setup.py file that I am using. This does *not* work.
I get the following error:
C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL
/nologo /INCREMENTAL:NO /LIBPATH:../../../../sword-build
/LIBPATH:C:\Python34\libs /LIBPATH:C:\Python34\PCbuild sword.lib
/EXPORT:PyInit__Sword build\temp.win32-3.4\Release\Sword.obj
/OUT:build\lib.win32-3.4\_Sword.pyd
/IMPLIB:build\temp.win32-3.4\Release\_Sword.lib
/MANIFESTFILE:build\temp.win32-3.4\Release\_Sword.pyd.manifest
LINK : fatal error LNK1181: cannot open input file 'sword.lib'
error: command 'C:\\Program Files\\Microsoft Visual Studio
10.0\\VC\\BIN\\link.exe' failed with exit status 1181
4. Because #3 does not work, running "C:\Python34\python.exe setup.py
install" doesn't either and gives the same error.

The problem is that I have no file named sword.lib, because libsword.sln
generates libsword.lib. I tried renaming it, and just got some different
errors.

(I'm also somewhat confused about the CMake path variables in the
setup.py file. Given my current directory tree:
Sword
bzip2
curl
icu-sword
sword-1.7.3
bindings
swig
python
include
lib
vcppmake
Release
sword-build
xz
What would be the appropriate values for CMAKE_CURRENT_SOURCE_DIR,
CMAKE_SOURCE_DIR, and CMAKE_BINARY_DIR? Currently I'm using the values
'sword-1.7.3/bindings/swig/python', 'sword-1.7.3', and 'sword-build',
respectively, but I'm not sure how setup.py would find files in the
lib/vcppmake/Release directory.)

I'm not quite sure what to try next. Is there a way I am not aware of to
obtain the sword.lib file that I need, or should I try building Sword
using CMake with ICU disabled?

Thank you.

-- Timothy
-------------- next part --------------
from distutils.core import setup, Extension
setup(name='sword',version='1.7.3',
maintainer='Sword Developers',
maintainer_email='sword-devel at crosswire.org',
url='http://www.crosswire.org/sword',
py_modules=['Sword'],
include_dirs=['../', '../../../include', '../../', '../../../'],
ext_modules = [Extension('_Sword',['Sword.cxx'],
libraries=[('sword')],
library_dirs=[('../../../../sword-build')],
)]
,)
R Johnson
2014-10-07 00:02:36 UTC
Permalink
I also tried changing the command in step 3 ("setup.py build") to use
libsword.lib rather than sword.lib by replacing the lines in the
setup.py file:

setup(name='sword',version='1.7.3',
libraries=[('sword')],

with:

setup(name='libsword',version='1.7.3',
libraries=[('libsword')],

but I got the same errors that I did when I tried renaming sword.lib to
libsword.lib.

I have attached the output from setup.py containing the errors, and
would appreciate any ideas as to what is causing them. I'm a SWIG
newbie, but could the errors mean that the SWIG interface (.i) files are
missing the definitions of certain functions/attributes? (I really don't
know what "unresolved external symbols" are, so this stuff is over my head.)

-- Timothy
-------------- next part --------------
...
Sword.cxx(85465) : warning C4101: 'e' : unreferenced local variable
C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:../../../../sword-build /LIBPATH:C:\Python34\libs /LIBPATH:C:\Python34\PCbuild libsword.lib /EXPORT:PyInit__Sword build\temp.win32-3.4\Release\Sword.obj /OUT:build\lib.win32-3.4\_Sword.pyd /IMPLIB:build\temp.win32-3.4\Release\_Sword.lib /MANIFESTFILE:build\temp.win32-3.4\Release\_Sword.pyd.manifest
Creating library build\temp.win32-3.4\Release\_Sword.lib and object build\temp.win32-3.4\Release\_Sword.exp
Sword.obj : error LNK2019: unresolved external symbol "public: static char * sword::SWBuf::nullStr" (?nullStr at ***@sword@@2PADA) referenced in function "char __cdecl sword_SWBuf_charAt2(class sword::SWBuf *,unsigned int)" (?sword_SWBuf_charAt2@@YADPAVSWBuf at sword@@I at Z)
Sword.obj : error LNK2019: unresolved external symbol "public: static class sword::SWVersion sword::SWVersion::currentVersion" (?currentVersion at ***@sword@@2V12 at A) referenced in function _Swig_var_SWVersion_currentVersion_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const sword::RawVerse::nl" (?nl at ***@sword@@2DB) referenced in function _Swig_var_RawVerse_nl_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::zVerse::uniqueIndexID" (?uniqueIndexID at ***@sword@@2QBDB) referenced in function _Swig_var_zVerse_uniqueIndexID_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const sword::RawStr::nl" (?nl at ***@sword@@2DB) referenced in function _Swig_var_RawStr_nl_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const sword::RawStr4::nl" (?nl at ***@sword@@2DB) referenced in function _Swig_var_RawStr4_nl_get
Sword.obj : error LNK2019: unresolved external symbol "struct sword::abbrev const * const sword::builtin_abbrevs" (?builtin_abbrevs at sword@@3QBUabbrev at ***@B) referenced in function _Swig_var_builtin_abbrevs_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::SWMgr::MODTYPE_BIBLES" (?MODTYPE_BIBLES at ***@sword@@2PBDB) referenced in function _Swig_var_SWMgr_MODTYPE_BIBLES_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::SWMgr::MODTYPE_COMMENTARIES" (?MODTYPE_COMMENTARIES at ***@sword@@2PBDB) referenced in function _Swig_var_SWMgr_MODTYPE_COMMENTARIES_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::SWMgr::MODTYPE_LEXDICTS" (?MODTYPE_LEXDICTS at ***@sword@@2PBDB) referenced in function _Swig_var_SWMgr_MODTYPE_LEXDICTS_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::SWMgr::MODTYPE_GENBOOKS" (?MODTYPE_GENBOOKS at ***@sword@@2PBDB) referenced in function _Swig_var_SWMgr_MODTYPE_GENBOOKS_get
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::SWMgr::MODTYPE_DAILYDEVOS" (?MODTYPE_DAILYDEVOS at ***@sword@@2PBDB) referenced in function _Swig_var_SWMgr_MODTYPE_DAILYDEVOS_get
Sword.obj : error LNK2019: unresolved external symbol "public: static bool sword::SWMgr::isICU" (?isICU at ***@sword@@2_NA) referenced in function _Swig_var_SWMgr_isICU_set
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::SWMgr::globalConfPath" (?globalConfPath at ***@sword@@2PBDB) referenced in function _Swig_var_SWMgr_globalConfPath_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::CREAT" (?CREAT at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_CREAT_set
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::APPEND" (?APPEND at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_APPEND_set
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::TRUNC" (?TRUNC at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_TRUNC_set
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::RDONLY" (?RDONLY at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_RDONLY_set
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::RDWR" (?RDWR at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_RDWR_set
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::WRONLY" (?WRONLY at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_WRONLY_set
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::IREAD" (?IREAD at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_IREAD_set
Sword.obj : error LNK2019: unresolved external symbol "public: static int sword::FileMgr::IWRITE" (?IWRITE at ***@sword@@2HA) referenced in function _Swig_var_FileMgr_IWRITE_set
Sword.obj : error LNK2019: unresolved external symbol "public: static char const * const sword::SWLocale::DEFAULT_LOCALE_NAME" (?DEFAULT_LOCALE_NAME at ***@sword@@2PBDB) referenced in function _Swig_var_SWLocale_DEFAULT_LOCALE_NAME_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::SWLog::LOG_ERROR" (?LOG_ERROR at ***@sword@@2HB) referenced in function _Swig_var_SWLog_LOG_ERROR_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::SWLog::LOG_WARN" (?LOG_WARN at ***@sword@@2HB) referenced in function _Swig_var_SWLog_LOG_WARN_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::SWLog::LOG_INFO" (?LOG_INFO at ***@sword@@2HB) referenced in function _Swig_var_SWLog_LOG_INFO_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::SWLog::LOG_TIMEDINFO" (?LOG_TIMEDINFO at ***@sword@@2HB) referenced in function _Swig_var_SWLog_LOG_TIMEDINFO_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::SWLog::LOG_DEBUG" (?LOG_DEBUG at ***@sword@@2HB) referenced in function _Swig_var_SWLog_LOG_DEBUG_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::InstallMgr::MODSTAT_OLDER" (?MODSTAT_OLDER at ***@sword@@2HB) referenced in function _Swig_var_InstallMgr_MODSTAT_OLDER_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::InstallMgr::MODSTAT_SAMEVERSION" (?MODSTAT_SAMEVERSION at ***@sword@@2HB) referenced in function _Swig_var_InstallMgr_MODSTAT_SAMEVERSION_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::InstallMgr::MODSTAT_UPDATED" (?MODSTAT_UPDATED at ***@sword@@2HB) referenced in function _Swig_var_InstallMgr_MODSTAT_UPDATED_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::InstallMgr::MODSTAT_NEW" (?MODSTAT_NEW at ***@sword@@2HB) referenced in function _Swig_var_InstallMgr_MODSTAT_NEW_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::InstallMgr::MODSTAT_CIPHERED" (?MODSTAT_CIPHERED at ***@sword@@2HB) referenced in function _Swig_var_InstallMgr_MODSTAT_CIPHERED_get
Sword.obj : error LNK2019: unresolved external symbol "public: static int const sword::InstallMgr::MODSTAT_CIPHERKEYPRESENT" (?MODSTAT_CIPHERKEYPRESENT at ***@sword@@2HB) referenced in function _Swig_var_InstallMgr_MODSTAT_CIPHERKEYPRESENT_get
Sword.obj : error LNK2019: unresolved external symbol "public: __thiscall sword::ThMLHTMLHREF::MyUserData::MyUserData(class sword::SWModule const *,class sword::SWKey const *)" (??0MyUserData at ***@sword@@QAE at ***@2 at ***@2@@Z) referenced in function "protected: virtual class sword::BasicFilterUserData * __thiscall sword::ThMLHTMLHREF::createUserData(class sword::SWModule const *,class sword::SWKey const *)" (?createUserData at ***@sword@@MAEPAVBasicFilterUserData at ***@PBVSWModule at ***@PBVSWKey at 2@@Z)
build\lib.win32-3.4\_Sword.pyd : fatal error LNK1120: 35 unresolved externals
error: command 'C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\BIN\\link.exe' failed with exit status 1120
Troy A. Griffitts
2014-10-07 00:06:49 UTC
Permalink
I could be completely off base here but I believe that those lines are looking for sword.dll, not sword.lib or libsword.lib.
Post by R Johnson
I also tried changing the command in step 3 ("setup.py build") to use
libsword.lib rather than sword.lib by replacing the lines in the
setup(name='sword',version='1.7.3',
libraries=[('sword')],
setup(name='libsword',version='1.7.3',
libraries=[('libsword')],
but I got the same errors that I did when I tried renaming sword.lib to
libsword.lib.
I have attached the output from setup.py containing the errors, and
would appreciate any ideas as to what is causing them. I'm a SWIG
newbie, but could the errors mean that the SWIG interface (.i) files are
missing the definitions of certain functions/attributes? (I really don't
know what "unresolved external symbols" are, so this stuff is over my head.)
-- Timothy
------------------------------------------------------------------------
_______________________________________________
sword-devel mailing list: sword-devel at crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20141007/f69c7569/attachment.html>
Ben Morgan
2014-10-07 00:09:45 UTC
Permalink
I think those items are all the data definitions.

I've run into errors like that before. If you are buildings Sword itself as
a DLL, you need to define the macro SWUSINGDLL while compiling the C++
bindings code for it all to work. I forget exactly how you change setup.py
to make it do that, though, but have a look here:
https://docs.python.org/2/extending/building.html

God Bless,
Ben
-------------------------------------------------------------
For I have no pleasure in the death of anyone,
declares the Lord God; so turn, and live.?
Ezekiel 18:32 (ESV)


On Tue, Oct 7, 2014 at 11:02 AM, R Johnson <
Post by R Johnson
I also tried changing the command in step 3 ("setup.py build") to use
libsword.lib rather than sword.lib by replacing the lines in the setup.py
setup(name='sword',version='1.7.3',
libraries=[('sword')],
setup(name='libsword',version='1.7.3',
libraries=[('libsword')],
but I got the same errors that I did when I tried renaming sword.lib to
libsword.lib.
I have attached the output from setup.py containing the errors, and would
appreciate any ideas as to what is causing them. I'm a SWIG newbie, but
could the errors mean that the SWIG interface (.i) files are missing the
definitions of certain functions/attributes? (I really don't know what
"unresolved external symbols" are, so this stuff is over my head.)
-- Timothy
_______________________________________________
sword-devel mailing list: sword-devel at crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20141007/16c8ff89/attachment.html>
Loading...