I needed to use Quantlib with Traits on MacOSX. As the Traits backends are not available in 64bit on MacOSX with EPD, I had to build a 32bit version of Quantlib and the related swig bindings to make it work. By default, Quantlib will be built in 64bit mode and you will get the following warning when building the Python swig bindings using a 32bit Python installation (python setup.py build):
ld: warning: in /opt/local/lib/libQuantLib.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
and the following error when trying to run the test (python setup.py test)
ImportError: dlopen(build/lib.macosx-10.5-i386-2.6/QuantLib/_QuantLib.so, 2): Symbol not found: __ZN8QuantLib12SmileSection6updateEv
Referenced from: /Users/dpinte/Downloads/QuantLib-SWIG-1.0/Python/build/lib.macosx-10.5-i386-2.6/QuantLib/_QuantLib.so
Expected in: flat namespace
in /Users/dpinte/Downloads/QuantLib-SWIG-1.0/Python/build/lib.macosx-10.5-i386-2.6/QuantLib/_QuantLib.so
1. Build Quantlib after making sure you do have Boost installed (you can use MacPorts for that):
export CFLAGS=-m32
export CPPFLAGS=-m32
export CXXFLAGS=-m32
./configure --enable-static --with-boost-include=/opt/local/include/ \
--with-boost-lib=/opt/local/lib/ --prefix=/opt/local/
make
make install
2. Build the swig bindings:
python setup.py build
python setup.py test
python setup.py install
And it should work fine :
...
Ran 25 tests in 0.889s
OK
I followed your instructions above, as I also run Mac OS X (10.6.8). I installed boost via macports. I then downloaded the Quantlib source (1.2.1) and compiled using the directions you supplied in (1). Finally, I built the swig bindings as you gave in (2). In running python setup.py test, I get
ImportError: dlopen(build/lib.macosx-10.5-i386-2.7/QuantLib/_QuantLib.so, 2): Symbol not found: __ZN8QuantLib12SmileSection6updateEv
Referenced from: /Users/sr/Downloads/QuantLib-SWIG-0.9.9/Python/build/lib.macosx-10.5-i386-2.7/QuantLib/_QuantLib.so
Expected in: flat namespace
in /Users/sr/Downloads/QuantLib-SWIG-0.9.9/Python/build/lib.macosx-10.5-i386-2.7/QuantLib/_QuantLib.so
Do you have any thoughts?
It sounds like you use an old version of the SWIG bindings. You should not be using the 0.9.9 version but the 1.2 version that can be found here:
http://sourceforge.net/projects/quantlib/files/QuantLib/1.2/other%20languages/