1
#include <ql/quantlib.hpp>
#include <boost/timer.hpp>
int main()
{
return 0;
}
庫安裝
sudo apt-get install libquantlib-1.1
QuantLib配置
$quantlib-config --libs
-L/usr/lib -lQuantLib
$ quantlib-config --cflags
-I/usr/include
$
編譯和鏈接步驟:
$ g++ test1.cpp -L/usr/lib -lQuantLib -I/usr/include -fPIC -o test1 /tmp/cc0GDoC4.o: In function `QuantLib::CPICoupon::indexFixing() const': test1.cpp:(.text._ZNK8QuantLib9CPICoupon11indexFixingEv[QuantLib::CPICoupon::indexFixing() const]+0x36): undefined reference to `QuantLib::CPICoupon::indexFixing(QuantLib::Date const&) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib22SwaptionVolatilityCubeE[vtable for QuantLib::SwaptionVolatilityCube]+0x100): undefined reference to `non-virtual thunk to QuantLib::SwaptionVolatilityDiscrete::update()' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib22SwaptionVolatilityCubeE0_NS_26SwaptionVolatilityDiscreteE[vtable for QuantLib::SwaptionVolatilityCube]+0xa8): undefined reference to `non-virtual thunk to QuantLib::SwaptionVolatilityDiscrete::update()' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib22CapFloorTermVolSurfaceE[vtable for QuantLib::CapFloorTermVolSurface]+0xc8): undefined reference to `non-virtual thunk to QuantLib::CapFloorTermVolSurface::update()' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib20CapFloorTermVolCurveE[vtable for QuantLib::CapFloorTermVolCurve]+0xc8): undefined reference to `non-virtual thunk to QuantLib::CapFloorTermVolCurve::update()' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib20SpreadedSmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x50): undefined reference to `QuantLib::SmileSection::optionPrice(double, QuantLib::Option::Type, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib20SpreadedSmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x58): undefined reference to `QuantLib::SmileSection::digitalOptionPrice(double, QuantLib::Option::Type, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib20SpreadedSmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x60): undefined reference to `QuantLib::SmileSection::vega(double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib20SpreadedSmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x68): undefined reference to `QuantLib::SmileSection::density(double, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib20SpreadedSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x50): undefined reference to `QuantLib::SmileSection::optionPrice(double, QuantLib::Option::Type, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib20SpreadedSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x58): undefined reference to `QuantLib::SmileSection::digitalOptionPrice(double, QuantLib::Option::Type, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib20SpreadedSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x60): undefined reference to `QuantLib::SmileSection::vega(double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib20SpreadedSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::SpreadedSmileSection]+0x68): undefined reference to `QuantLib::SmileSection::density(double, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib10FdmBatesOpE[vtable for QuantLib::FdmBatesOp]+0x60): undefined reference to `QuantLib::FdmBatesOp::toMatrixDecomp() const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib16FlatSmileSectionE[vtable for QuantLib::FlatSmileSection]+0x50): undefined reference to `QuantLib::SmileSection::optionPrice(double, QuantLib::Option::Type, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib16FlatSmileSectionE[vtable for QuantLib::FlatSmileSection]+0x58): undefined reference to `QuantLib::SmileSection::digitalOptionPrice(double, QuantLib::Option::Type, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib16FlatSmileSectionE[vtable for QuantLib::FlatSmileSection]+0x60): undefined reference to `QuantLib::SmileSection::vega(double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib16FlatSmileSectionE[vtable for QuantLib::FlatSmileSection]+0x68): undefined reference to `QuantLib::SmileSection::density(double, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib16FlatSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::FlatSmileSection]+0x50): undefined reference to `QuantLib::SmileSection::optionPrice(double, QuantLib::Option::Type, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib16FlatSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::FlatSmileSection]+0x58): undefined reference to `QuantLib::SmileSection::digitalOptionPrice(double, QuantLib::Option::Type, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib16FlatSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::FlatSmileSection]+0x60): undefined reference to `QuantLib::SmileSection::vega(double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTCN8QuantLib16FlatSmileSectionE0_NS_12SmileSectionE[vtable for QuantLib::FlatSmileSection]+0x68): undefined reference to `QuantLib::SmileSection::density(double, double, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib27CPICapFloorTermPriceSurfaceE[vtable for QuantLib::CPICapFloorTermPriceSurface]+0xb0): undefined reference to `QuantLib::CPICapFloorTermPriceSurface::price(QuantLib::Period const&, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib27CPICapFloorTermPriceSurfaceE[vtable for QuantLib::CPICapFloorTermPriceSurface]+0xb8): undefined reference to `QuantLib::CPICapFloorTermPriceSurface::capPrice(QuantLib::Period const&, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib27CPICapFloorTermPriceSurfaceE[vtable for QuantLib::CPICapFloorTermPriceSurface]+0xc0): undefined reference to `QuantLib::CPICapFloorTermPriceSurface::floorPrice(QuantLib::Period const&, double) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib27CPICapFloorTermPriceSurfaceE[vtable for QuantLib::CPICapFloorTermPriceSurface]+0x128): undefined reference to `QuantLib::CPICapFloorTermPriceSurface::cpiOptionDateFromTenor(QuantLib::Period const&) const' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib9CPICouponE[vtable for QuantLib::CPICoupon]+0x30): undefined reference to `QuantLib::CPICoupon::accept(QuantLib::AcyclicVisitor&)' /tmp/cc0GDoC4.o:(.data.rel.ro._ZTVN8QuantLib9CPICouponE[vtable for QuantLib::CPICoupon]+0x78): undefined reference to `QuantLib::CPICoupon::checkPricerImpl(boost::shared_ptr const&) const' collect2: ld returned 1 exit status
你能幫我嗎?
我嘗試安裝libquantlib0,但它仍然給我同樣的問題。我嘗試按照[鏈接] http://quantess.net/2012/09/26/quantlib-get-it-working-on-ubuntu/中的步驟手動安裝軟件包,但仍面臨同樣的問題。有什麼想法嗎 ? – user721570
你重新編譯了你的程序嗎?另外,是否有可能你還在拿起新的標題? 'quantlib-config'現在說什麼,你在用什麼? –