I encountered the same error as you did. Linking with g++ instead of gcc or ld solved the issue for me.
My steps:
swig -python -c++ example.i
g++ -O2 -fPIC -c example.c
g++ -O2 -fPIC -c example_wrap.cxx -I /usr/include/python2.7
g++ -shared example.o example_wrap.o -o _example.so