crfsuite icon indicating copy to clipboard operation
crfsuite copied to clipboard

Undefined symbols when building python wrapper on OSX (solution)

Open bellecp opened this issue 12 years ago • 5 comments

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).

bellecp avatar Aug 03 '12 15:08 bellecp

Thanks for the tip !

adurieux avatar Dec 24 '12 11:12 adurieux

Thank for the help! I just encountered it.

xwzhu avatar May 04 '13 18:05 xwzhu

And if you have a newer version of MacOS, just replace 10.7 by 10.X

adurieux avatar Jul 15 '13 17:07 adurieux

Thanks so much!!

ghost avatar Oct 08 '13 01:10 ghost

:+1: *5

debovis avatar Nov 06 '14 20:11 debovis