量化庫
在 Mac 中使用 Visual Studio Code 執行 Quantlib
我想
Quantlib
和Visual Studio Code
in一起跑Mac
。我已按照https://www.quantlib.org/install/macosx.shtmlQuantlib
中的說明成功安裝,它正在使用.Mac``Xcode
但是,當我嘗試執行以下虛擬程式碼時,
Quantlib
我無法編譯。#include <iostream> #include <iomanip> #include <ql/option.hpp> using namespace QuantLib; int main() { }
我得到的錯誤 -
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 Try-731982.o boost::unordered::detail::table<boost::unordered::detail::set<std::__1::allocator<QuantLib::Observer*>, QuantLib::Observer*, boost::hash<QuantLib::Observer*>, std::__1::equal_to<QuantLib::Observer*> > >::get_bucket_pointer(unsigned long) const in Try-731982.o boost::shared_ptr<QuantLib::DayCounter::Impl>::operator->() const in Try-731982.o boost::shared_ptr<QuantLib::Calendar::Impl>::operator->() const in Try-731982.o boost::shared_ptr<QuantLib::IndexManager>::operator*() const in Try-731982.o boost::unordered::detail::functions<boost::hash<boost::shared_ptr<QuantLib::Observable> >, std::__1::equal_to<boost::shared_ptr<QuantLib::Observable> > >::~functions() in Try-731982.o boost::unordered::detail::table<boost::unordered::detail::set<std::__1::allocator<boost::shared_ptr<QuantLib::Observable> >, boost::shared_ptr<QuantLib::Observable>, boost::hash<boost::shared_ptr<QuantLib::Observable> >, std::__1::equal_to<boost::shared_ptr<QuantLib::Observable> > > >::get_bucket_pointer(unsigned long) const in Try-731982.o ... "QuantLib::Observable::notifyObservers()", referenced from: QuantLib::InterestRateIndex::update() in Try-731982.o "QuantLib::TermStructure::update()", referenced from: vtable for QuantLib::TermStructure in Try-731982.o "QuantLib::Date::Date()", referenced from: QuantLib::TermStructure::timeFromReference(QuantLib::Date const&) const in Try-731982.o "QuantLib::Error::Error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from: QuantLib::TermStructure::settlementDays() const in Try-731982.o QuantLib::InterestRateIndex::valueDate(QuantLib::Date const&) const in Try-731982.o QuantLib::InterestRateIndex::pastFixing(QuantLib::Date const&) const in Try-731982.o QuantLib::DayCounter::yearFraction(QuantLib::Date const&, QuantLib::Date const&, QuantLib::Date const&, QuantLib::Date const&) const in Try-731982.o QuantLib::Calendar::isBusinessDay(QuantLib::Date const&) const in Try-731982.o "QuantLib::Index::addFixing(QuantLib::Date const&, double, bool)", referenced from: vtable for QuantLib::InterestRateIndex in Try-731982.o "QuantLib::Coupon::accept(QuantLib::AcyclicVisitor&)", referenced from: vtable for QuantLib::Coupon in Try-731982.o "QuantLib::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, QuantLib::Date const&)", referenced from: QuantLib::InterestRateIndex::valueDate(QuantLib::Date const&) const in Try-731982.o QuantLib::InterestRateIndex::pastFixing(QuantLib::Date const&) const in Try-731982.o "QuantLib::IndexManager::getHistory(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from: QuantLib::Index::timeSeries() const in Try-731982.o "QuantLib::TermStructure::referenceDate() const", referenced from: vtable for QuantLib::TermStructure in Try-731982.o "QuantLib::InterestRateIndex::fixing(QuantLib::Date const&, bool) const", referenced from: vtable for QuantLib::InterestRateIndex in Try-731982.o "QuantLib::Calendar::advance(QuantLib::Date const&, int, QuantLib::TimeUnit, QuantLib::BusinessDayConvention, bool) const", referenced from: QuantLib::InterestRateIndex::valueDate(QuantLib::Date const&) const in Try-731982.o "QuantLib::CashFlow::hasOccurred(QuantLib::Date const&, boost::optional<bool>) const", referenced from: vtable for QuantLib::Coupon in Try-731982.o "typeinfo for QuantLib::Error", referenced from: QuantLib::TermStructure::settlementDays() const in Try-731982.o QuantLib::InterestRateIndex::valueDate(QuantLib::Date const&) const in Try-731982.o QuantLib::InterestRateIndex::pastFixing(QuantLib::Date const&) const in Try-731982.o QuantLib::DayCounter::yearFraction(QuantLib::Date const&, QuantLib::Date const&, QuantLib::Date const&, QuantLib::Date const&) const in Try-731982.o QuantLib::Calendar::isBusinessDay(QuantLib::Date const&) const in Try-731982.o "typeinfo for QuantLib::Index", referenced from: typeinfo for QuantLib::InterestRateIndex in Try-731982.o "typeinfo for QuantLib::CashFlow", referenced from: typeinfo for QuantLib::Coupon in Try-731982.o "vtable for QuantLib::Error", referenced from: QuantLib::Error::~Error() in Try-731982.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "virtual thunk to QuantLib::TermStructure::update()", referenced from: vtable for QuantLib::TermStructure in Try-731982.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) [Done] exited with code=1 in 28.615 seconds
任何如何成功執行
Quantlib C++
程式碼的見解Visual Studio Code in Mac
都將非常有幫助。非常感謝,
程式碼已編譯,但沒有連結。您需要添加
/usr/local/lib/libQuantLib.dylib
到建構中(或者.a
,根據您編譯 QuantLib 的方式,檢查您在 中擁有哪些文件/usr/local/lib
)。我對 VS Code 不熟悉,因此無法逐步指導您,但您可能會找到有關如何將庫添加到建構的說明。