Login  Register

QuantLib on Mac

Posted by bo.zhao on Jun 27, 2014; 10:20pm
URL: http://quantlib.414.s1.nabble.com/QuantLib-on-Mac-tp15555.html

Dear all,

I am quite new on using QuantLib, so sorry for this basic question.

I have been trying to use QuantLib on Mac, for C++ coding. Boost and QuantLib are installed following the instruction provided on QuantLib website. Xcode is configured so that C++ coding is supported. 

I was writing a little piece of code to see how to use QuantLib. This code does nothing, but including the QuantLib header QuantLib.cpp and the timer header in Boost library. Unfortunately, when I built the code, a lot of compiling errors were thrown out. I just wonder whether you could help me out. 

The code I have written is as the follow.

#include <ql/quantlib.hpp>


#include <boost/timer.hpp>


#include <iostream>


using namespace std;


int main(int argc, const char * argv[])

{


    // insert code here...

    boost::timer time;

    double t = time.elapsed();

    

    cout << "the time is " << t << "\n";

    

    double tmp;

    cin >> tmp;

    

    return 0;

}


The errors messages are like:


Ld /Users/zrm/Library/Developer/Xcode/DerivedData/SimpleMC1-dnzreinrixododgttxobkughqdsw/Build/Products/Debug/SimpleMC1 normal x86_64

    cd "/Users/zrm/Work/C++ Projects/SimpleMC1/SimpleMC1"

    export MACOSX_DEPLOYMENT_TARGET=10.9

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/zrm/Library/Developer/Xcode/DerivedData/SimpleMC1-dnzreinrixododgttxobkughqdsw/Build/Products/Debug -F/Users/zrm/Library/Developer/Xcode/DerivedData/SimpleMC1-dnzreinrixododgttxobkughqdsw/Build/Products/Debug -filelist /Users/zrm/Library/Developer/Xcode/DerivedData/SimpleMC1-dnzreinrixododgttxobkughqdsw/Build/Intermediates/SimpleMC1.build/Debug/SimpleMC1.build/Objects-normal/x86_64/SimpleMC1.LinkFileList -mmacosx-version-min=10.9 -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/zrm/Library/Developer/Xcode/DerivedData/SimpleMC1-dnzreinrixododgttxobkughqdsw/Build/Intermediates/SimpleMC1.build/Debug/SimpleMC1.build/Objects-normal/x86_64/SimpleMC1_dependency_info.dat -o /Users/zrm/Library/Developer/Xcode/DerivedData/SimpleMC1-dnzreinrixododgttxobkughqdsw/Build/Products/Debug/SimpleMC1


Undefined symbols for architecture x86_64:

  "boost::assertion_failed(char const*, char const*, char const*, long)", referenced from:

      boost::shared_ptr<QuantLib::Observable>::operator->() const in main.o

      boost::shared_ptr<QuantLib::DiscretizedAsset>::operator->() const in main.o

      boost::shared_ptr<QuantLib::IborIndex>::operator->() const in main.o

      boost::shared_ptr<QuantLib::Quote>::operator->() const in main.o

      boost::shared_ptr<QuantLib::DefaultProbabilityTermStructure>::operator->() const in main.o

      boost::shared_ptr<QuantLib::Exercise>::operator->() const in main.o

      boost::shared_ptr<QuantLib::ZeroInflationIndex>::operator->() const in main.o

      ...

  "QuantLib::InterestRate::impliedRate(double, QuantLib::DayCounter const&, QuantLib::Compounding, QuantLib::Frequency, double)", referenced from:

      QuantLib::InterestRate::equivalentRate(QuantLib::Compounding, QuantLib::Frequency, double) const in main.o

  "QuantLib::InterestRate::InterestRate(double, QuantLib::DayCounter const&, QuantLib::Compounding, QuantLib::Frequency)", referenced from:

      QuantLib::FlatForward::performCalculations() const in main.o

      QuantLib::ZeroSpreadedTermStructure::zeroYieldImpl(double) const in main.o

  "QuantLib::SmileSection::update()", referenced from:

      vtable for QuantLib::FlatSmileSection in main.o

      construction vtable for QuantLib::SmileSection-in-QuantLib::FlatSmileSection in main.o

      construction vtable for QuantLib::SmileSection-in-QuantLib::SpreadedSmileSection in main.o

  "QuantLib::MultiStepSwap::nextTimeStep(QuantLib::CurveState const&, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >&, std::__1::vector<std::__1::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::__1::allocator<QuantLib::MarketModelMultiProduct::CashFlow> >, std::__1::allocator<std::__1::vector<QuantLib::MarketModelMultiProduct::CashFlow, std::__1::allocator<QuantLib::MarketModelMultiProduct::CashFlow> > > >&)", referenced from:

      vtable for QuantLib::MultiStepSwap in main.o

  "QuantLib::TermStructure::update()", referenced from:

      QuantLib::DefaultProbabilityTermStructure::update() in main.o

      QuantLib::FittedBondDiscountCurve::update() in main.o

      QuantLib::ForwardSpreadedTermStructure::update() in main.o

      QuantLib::ZeroSpreadedTermStructure::update() in main.o

      vtable for QuantLib::TermStructure in main.o

      vtable for QuantLib::VolatilityTermStructure in main.o

      construction vtable for QuantLib::TermStructure-in-QuantLib::VolatilityTermStructure in main.o

      ...

      ...

      ...

      ...


      vtable for QuantLib::SwaptionVolatilityCube in main.o

      construction vtable for QuantLib::SwaptionVolatilityDiscrete-in-QuantLib::SwaptionVolatilityCube in main.o

  "non-virtual thunk to QuantLib::ExtendedBlackVarianceSurface::update()", referenced from:

      vtable for QuantLib::ExtendedBlackVarianceSurface in main.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Showing first 200 notices only

Showing first 200 errors only




If I comment out the line, #include <ql/quantlib.hpp>, then the code is built and run as expected. So that seems the Boost library might be fine.

Thank you very much for your help in advance.

Kind regards,

Bo

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users