When binding C ++ code using swig, use setup.py to create a shared object. When I try to do it on Mac OS X, the library itself is compiled with g ++, but when I try to compile it with Clang, I get an error.
Like this.
$ python setup.py build_ext
running build_ext
building '_Mykytea' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c mykytea_wrap.cxx -o build/temp.macosx-10.8-intel-2.7/mykytea_wrap.o
(Abbreviation)
In file included from mykytea_wrap.cxx:3481:
In file included from ./mykytea.hpp:9:
/usr/local/include/kytea/kytea.h:128:24: error: implicit instantiation of undefined template
'kytea::Dictionary<kytea::ModelTagEntry>'
if(dict_ != 0) delete dict_;
^
/usr/local/include/kytea/kytea.h:34:26: note: template is declared here
template <class T> class Dictionary;
^
2 warnings and 1 error generated.
error: command 'cc' failed with exit status 1
So, if you don't call Clang, you can leave it alone and compile it with gcc.
$ ARCHFLAGS="-arch x86_64" CC=gcc CXX=g++ python setup.py build_ext
And it is sufficient.
Actually, it may be better to write it in setup.py, but I wonder if it is possible to dynamically determine what the original library was compiled with.
So, congratulations Kytea's Python bindings is now compatible with the latest 0.4.4.
Recommended Posts