0

I am trying to install the Python PyQL library which wraps Quantlib but it seems to be failing to find some boost headers.

I already have the latest version of Quantlib (1.3) working and located in the /usr/local/lib directory, along with Boost 1.5:

xxx@LILJEN:/usr/local/lib$ ls
boost  boost_1_50_0  libQuantLib.a  libQuantLib.la  libQuantLib.so  libQuantLib.so.0  libQuantLib.so.0.0.0  python2.7  python3.3  QuantLib-1.3  QuantLib-SWIG-1.3  R  site_ruby

I have Cython 0.2 installed:

>>> pkg_resources.get_distribution("Cython").version
'0.20'

When I go into the pyql directory where I downloaded the package and do a make build command I get an issue with the Boost library, as otherwise it seems to be "Cythonizing" everthing properly. I note that that Github instructions said that I should "patch" Cython 0.16, but since I am already on 0.2 I assume this is not necessary. Here is what the build says:

xxx@LILJEN:~/Downloads/pyql$ sudo make build
python setup.py build_ext --inplace
/usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
  warnings.warn(msg)
missing cimport in module 'quantlib.time': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/option.pyx
Compiling quantlib/quotes.pyx because it changed.
Compiling quantlib/interest_rate.pyx because it changed.
Compiling quantlib/time/calendar.pyx because it changed.
Compiling quantlib/time/schedule.pyx because it changed.
Compiling quantlib/time/date.pyx because it changed.
Compiling quantlib/time/daycounter.pyx because it changed.
Compiling quantlib/time/daycounters/actual_actual.pyx because it changed.
Compiling quantlib/time/daycounters/thirty360.pyx because it changed.
Compiling quantlib/time/calendars/germany.pyx because it changed.
Compiling quantlib/time/calendars/united_states.pyx because it changed.
Compiling quantlib/time/calendars/united_kingdom.pyx because it changed.
Compiling quantlib/time/calendars/null_calendar.pyx because it changed.
Compiling quantlib/time/calendars/jointcalendar.pyx because it changed.
Compiling quantlib/instruments/swap.pyx because it changed.
Compiling quantlib/pricingengines/credit.pyx because it changed.
Compiling quantlib/pricingengines/swap.pyx because it changed.
Compiling quantlib/pricingengines/bond.pyx because it changed.
Compiling quantlib/pricingengines/blackformula.pyx because it changed.
Compiling quantlib/pricingengines/engine.pyx because it changed.
Compiling quantlib/pricingengines/vanilla/mcvanillaengine.pyx because it changed.
Compiling quantlib/pricingengines/vanilla/vanilla.pyx because it changed.
Compiling quantlib/sim/simulate.pyx because it changed.
Compiling quantlib/processes/bates_process.pyx because it changed.
Compiling quantlib/processes/black_scholes_process.pyx because it changed.
Compiling quantlib/processes/heston_process.pyx because it changed.
Compiling quantlib/math/optimization.pyx because it changed.
Compiling quantlib/termstructures/default_term_structure.pyx because it changed.
Compiling quantlib/termstructures/credit/piecewise_default_curve.pyx because it changed.
Compiling quantlib/termstructures/credit/default_probability_helpers.pyx because it changed.
Compiling quantlib/termstructures/volatility/equityfx/black_vol_term_structure.pyx because it changed.
Compiling quantlib/termstructures/yields/yield_term_structure.pyx because it changed.
Compiling quantlib/termstructures/yields/zero_curve.pyx because it changed.
Compiling quantlib/termstructures/yields/piecewise_yield_curve.pyx because it changed.
Compiling quantlib/termstructures/yields/rate_helpers.pyx because it changed.
Compiling quantlib/termstructures/yields/flat_forward.pyx because it changed.
Compiling quantlib/models/equity/bates_model.pyx because it changed.
Compiling quantlib/models/equity/heston_model.pyx because it changed.
Cythonizing quantlib/instruments/swap.pyx
Cythonizing quantlib/interest_rate.pyx
Cythonizing quantlib/math/optimization.pyx
Cythonizing quantlib/models/equity/bates_model.pyx
Cythonizing quantlib/models/equity/heston_model.pyx
Cythonizing quantlib/pricingengines/blackformula.pyx
Cythonizing quantlib/pricingengines/bond.pyx
Cythonizing quantlib/pricingengines/credit.pyx
Cythonizing quantlib/pricingengines/engine.pyx
Cythonizing quantlib/pricingengines/swap.pyx
Cythonizing quantlib/pricingengines/vanilla/mcvanillaengine.pyx
Cythonizing quantlib/pricingengines/vanilla/vanilla.pyx
Cythonizing quantlib/processes/bates_process.pyx
Cythonizing quantlib/processes/black_scholes_process.pyx
Cythonizing quantlib/processes/heston_process.pyx
Cythonizing quantlib/quotes.pyx
Cythonizing quantlib/sim/simulate.pyx
Cythonizing quantlib/termstructures/credit/default_probability_helpers.pyx
Cythonizing quantlib/termstructures/credit/piecewise_default_curve.pyx
Cythonizing quantlib/termstructures/default_term_structure.pyx
Cythonizing quantlib/termstructures/volatility/equityfx/black_vol_term_structure.pyx
Cythonizing quantlib/termstructures/yields/flat_forward.pyx
Cythonizing quantlib/termstructures/yields/piecewise_yield_curve.pyx
Cythonizing quantlib/termstructures/yields/rate_helpers.pyx
Cythonizing quantlib/termstructures/yields/yield_term_structure.pyx
Cythonizing quantlib/termstructures/yields/zero_curve.pyx
Cythonizing quantlib/time/calendar.pyx
Cythonizing quantlib/time/calendars/germany.pyx
Cythonizing quantlib/time/calendars/jointcalendar.pyx
Cythonizing quantlib/time/calendars/null_calendar.pyx
Cythonizing quantlib/time/calendars/united_kingdom.pyx
Cythonizing quantlib/time/calendars/united_states.pyx
Cythonizing quantlib/time/date.pyx
Cythonizing quantlib/time/daycounter.pyx
Cythonizing quantlib/time/daycounters/actual_actual.pyx
Cythonizing quantlib/time/daycounters/thirty360.pyx
Cythonizing quantlib/time/schedule.pyx
running build_ext
building 'quantlib.cashflow' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/quantlib
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_CONFIG_H -I/usr/local/include -I/usr/include -I. -I./cpp_layer -I/usr/include/python2.7 -c quantlib/cashflow.cpp -o build/temp.linux-x86_64-2.7/quantlib/cashflow.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
quantlib/cashflow.cpp:342:32: fatal error: boost/shared_ptr.hpp: No such file or directory
 #include "boost/shared_ptr.hpp"
                                ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
make: *** [build] Error 1

It doesn't seem to be able to find the boost library, even though this is clearly installed and working since I compiled Quantlib from scratch successfully and the test suite works. Any hints as to where I might be getting something wrong?

It's Ubuntu 13.10 and the default installed Python 2.7. Essentially this is a newly installed system with all the latest libraries (except for Boost which I kept at 1.5).

Fwiw python setup.py install does not work either, but I have the regular SWIG Quantlib library working fine in Python.


ADDENDUM

I believe the "error" I have is that I closely followed this excellent page on how to install Quantlib on Ubuntu. That page talks about Boost in the usr/local/lib directory, and I copied and pasted its commands. Quantlib compiled perfectly because the Boost directory was communicated via the export command as per the page, but pyql needed also to have this directory specified in setup.py. It is a matter of ensuring that the line under sys.platform = "linux2", specifying the INCLUDE_DIRS to usr/local/lib rather than the default usr/local/include. I write this addendum because I believe many users may also google search "install Quantlib Ubuntu" and find this page, therefore this problem may recur for a number of people.

4

1 回答 1

1

如果您查看启动编译器的命令行,您会看到

-I/usr/local/include -I/usr/include -I. -I./cpp_layer -I/usr/include/python2.7

这些标志告诉编译器在哪里寻找头文件。您的 Boost 标头不在其中任何一个中(这很奇怪:标头通常位于 /usr/local/include 的某个位置。您是否自己将它们复制到 /usr/local/lib 中?)因此编译器找不到它们。

您可以:

  • 移动 /usr/local/include 中的 boost 目录(这将是名为“boost”的目录,而不是名为“boost_1_50_0”的目录),或者
  • 将附加标志传递-I/usr/local/lib/boost_1_50_0给编译器,以便它可以在当前位置找到它们。执行此操作的方法取决于您的 setup.py 脚本。
于 2014-01-22T13:43:09.173 回答