crfsuite
crfsuite copied to clipboard
Undefined symbols when building python wrapper on OSX (solution)
I had undefined symbols issues when trying to build the python wrapper (using the "modified" export_wrap.cpp as suggested in README).
The undefined symbols error can be seen there : https://gist.github.com/3248610
It was issued while running python setup.py build_ext
by the command
g++ -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/crfsuite.o build/temp.macosx-10.7-intel-2.7/export_wrap.o -L/usr/local/lib -lcrfsuite -o build/lib.macosx-10.7-intel-2.7/_crfsuite.so -shared
After some research I managed to resolve the issue by passing to the linker the option -undefined dynamic_lookup
(found in man ld
)
So finally, this worked:
python setup.py build_ext
g++ -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/crfsuite.o build/temp.macosx-10.7-intel-2.7/export_wrap.o -L/usr/local/lib -lcrfsuite -o build/lib.macosx-10.7-intel-2.7/_crfsuite.so -shared -Wl,-undefined,dynamic_lookup
python setup.py build_ext
python setup.py install
(the option can be passed to the linker with -Wl,-undefined,dynamic_lookup
)
It may save some hours to someone else..!
(I am not sure how to change the code to prevent this error. If one gives me some clues I can propose a pull request).
Thanks for the tip !
Thank for the help! I just encountered it.
And if you have a newer version of MacOS, just replace 10.7 by 10.X
Thanks so much!!
:+1: *5