error LNK2019 and fatal error LNK1120

492 views Asked by At

I encouneter a problem when compiling my projet. When I set this line:

boost::shared_ptr mySwap;

I have no problem but when I set this one:

boost::shared_ptr mySwap(new OvernightVsLiborBasisSwap(OvernightVsLiborBasisSwap::PayerOvernight, 1.0, scheduleOis, indexOis, dayCountOis, 1.0, scheduleLibor, indexLibor, dayCountLibor));

I have the following error message

excelFunctions.obj : error LNK2019: unresolved external symbol "public: __thiscall ModLibNY::OvernightVsLiborBasisSwap::OvernightVsLiborBasisSwap(enum ModLibNY::OvernightVsLiborBasisSwap::Type,double,class QuantLib::Schedule const &,class boost::shared_ptr const &,class QuantLib::DayCounter const &,double,class QuantLib::Schedule const &,class boost::shared_ptr const &,class 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) referenced in function "class xlw::NCMatrix __cdecl getOisLiborSwapCurve(class xlw::CellMatrix const &,class xlw::CellMatrix const &,class xlw::CellMatrix const &,class xlw::CellMatrix const &,double const &)" (?getOisLiborSwapCurve@@YA?AVNCMatrix@xlw@@ABVCellMatrix@2@000ABN@Z) 3>.\Debug\ExplainPnL.xll : fatal error LNK1120: 1 unresolved externals

The object OvernightVsLiborBasisSwap is part of my own-made static library ModLibNY which is included. The first lines of my code constain:

#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;

What is very wierd is that I ve the error when I use the constructor. For information it is declared in the .hpp file as

#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);

and defined in the .cpp file:

#include "StdAfx.h"

#include "overnightvsliborbasisswap.hpp"

#include <ql/quantlib.hpp>

using namespace QuantLib;

namespace 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);
}

... If someone have an idea of the problem origin, please let me know!

Thanks

0

There are 0 answers