编译我的项目时,我遇到了一个问题。当我设置这一行时:
boost :: shared_ptr mySwap;
我没有问题但是当我设置这个时:
boost :: shared_ptr mySwap(new OvernightVsLiborBasisSwap(OvernightVsLiborBasisSwap :: PayerOvernight, 1.0, scheduleOis, indexOis, dayCountOis, 1.0, scheduleLibor, indexLibor, dayCountLibor));
我有以下错误消息
excelFunctions.obj:错误LNK2019:未解析的外部符号“public:__thiscall ModLibNY :: OvernightVsLiborBasisSwap :: OvernightVsLiborBasisSwap(enum ModLibNY :: OvernightVsLiborBasisSwap :: Type,double,class QuantLib :: Schedule const&,class boost :: shared_ptr const&,类QuantLib :: DayCounter const&,double,类QuantLib :: Schedule const&,类boost :: shared_ptr const&,类QuantLib :: DayCounter const&,double,double,bool,bool, class boost :: optional,class boost :: optional)“(?? 0OvernightVsLiborBasisSwap @ ModLibNY @@ QAE @ W4Type @ 01 @ NABVSchedule @QuantLib @@ ABV?$ shared_ptr @ VOvernightIndex @QuantLib @@@ boost @@ ABVDayCounter @ 4 @ N1ABV?$ shared_ptr @ VIborIndex @QuantLib @@@ 6 @ 3NN_N5V?$ optional @ W4BusinessDayConvention @QuantLib @@@ 6 @ 6 @ Z)在函数“class xlw :: NCMatrix __cdecl getOisLiborSwapCurve”中引用(类xlw :: CellMatrix const& ,类xlw :: CellMatrix const&,类xlw :: CellMatrix const&,类xlw :: CellMatrix const&,double const&)“(?getOisLiborSwapCurv Ë@@ YA?AVNCMatrix @ XLW @@ ABVCellMatrix @ 2 @ 000ABN @ Z) 3>。\ Debug \ ExplainPnL.xll:致命错误LNK1120:1个未解析的外部
对象OvernightVsLiborBasisSwap是我自己创建的静态库ModLibNY的一部分,它包含在内。我的代码的第一行是:
#include <ql/quantlib.hpp>
#include <ml/modlibny.hpp>
#include <ml/swaps/overnightvsliborbasisswap.hpp>
using namespace std;
using namespace xlw;
using namespace QuantLib;
using namespace ModLibNY;
我使用构造函数时出现错误是非常奇怪的。有关信息,它在.hpp文件中声明为
#ifndef overnight_vs_libor_basis_swap_hpp
#define overnight_vs_libor_basis_swap_hpp
#include <ql/quantlib.hpp>
using namespace std;
using namespace QuantLib;
namespace ModLibNY {
class InterestRateIndex;
class OvernightVsLiborBasisSwap : public Swap {
public:
enum Type { ReceiverOvernight = -1, PayerOvernight = 1 };
class arguments;
class results;
class engine;
OvernightVsLiborBasisSwap(
const OvernightVsLiborBasisSwap::Type type,
const Real nominal1,
const Schedule &schedule1,
const boost::shared_ptr<OvernightIndex> &index1,
const DayCounter &dayCount1,
const Real nominal2,
const Schedule &schedule2,
const boost::shared_ptr<IborIndex> &index2,
const DayCounter &dayCount2,
const Real spread1 = 0.0,
const Real spread2 = 0.0,
const bool intermediateCapitalExchange = false,
const bool finalCapitalExchange = false,
boost::optional<BusinessDayConvention> paymentConvention1 =
boost::none,
boost::optional<BusinessDayConvention> paymentConvention2 =
boost::none);
并在.cpp文件中定义:
#include "StdAfx.h"
#include "overnightvsliborbasisswap.hpp"
#include <ql/quantlib.hpp>
using namespace QuantLib;
命名空间ModLibNY {
OvernightVsLiborBasisSwap::OvernightVsLiborBasisSwap(
const OvernightVsLiborBasisSwap::Type type,
const Real nominal1,
const Schedule &schedule1,
const boost::shared_ptr<OvernightIndex> &index1,
const DayCounter &dayCount1,
const Real nominal2,
const Schedule &schedule2,
const boost::shared_ptr<IborIndex> &index2,
const DayCounter &dayCount2,
const Real spread1,
const Real spread2,
const bool intermediateCapitalExchange,
const bool finalCapitalExchange,
boost::optional<BusinessDayConvention> paymentConvention1,
boost::optional<BusinessDayConvention> paymentConvention2)
: Swap(2),
type_(type),
nominal1_(std::vector<Real>(schedule1.size() - 1, nominal1)),
nominal2_(std::vector<Real>(schedule2.size() - 1, nominal2)),
schedule1_(schedule1),
schedule2_(schedule2),
index1_(index1),
index2_(index2),
dayCount1_(dayCount1),
dayCount2_(dayCount2),
intermediateCapitalExchange_(intermediateCapitalExchange),
finalCapitalExchange_(finalCapitalExchange)
{
init(paymentConvention1, paymentConvention2);
}
...如果有人知道问题根源,请告诉我!
由于