C++ C+中的指针困难+;/链接错误

C++ C+中的指针困难+;/链接错误,c++,boost,linker-errors,shared-ptr,quantlib,C++,Boost,Linker Errors,Shared Ptr,Quantlib,编译代码时,出现以下错误: LNK2019未解析外部符号“公共:类QuantLib::矩阵 const&u cdecl SachLib::AWDCalculator::RSB(void)const“ (?RSB@AWDCalculator@萨克利布@@QEBAAEBVMatrix@QuantLib@@XZ)参考 在功能中“受保护:无效”\uuu cdecl SachLib::CalculationEngine\u Sach::设置结果(类 boost::shared_ptr&)const“ (?

编译代码时,出现以下错误:

LNK2019未解析外部符号“公共:类QuantLib::矩阵 const&u cdecl SachLib::AWDCalculator::RSB(void)const“ (?RSB@AWDCalculator@萨克利布@@QEBAAEBVMatrix@QuantLib@@XZ)参考 在功能中“受保护:无效”\uuu cdecl SachLib::CalculationEngine\u Sach::设置结果(类 boost::shared_ptr&)const“ (?套_results@CalculationEngine_Sach@SachLib@@IEBAXAEAV?$shared_ptr@VAWDCalculator@SachLib@@@@boost@@@Z)

可在第1行的CalculationEngine_Sach.obj中找到

这是我的密码:

Abwicklungsdreieck和Gewichtungsfaktoren基本上由一个矩阵组成,并由各自的读取器获得。我认为他们方法的名称是明确的

main.cpp:

#include "AbwicklungsdreieckReader.h"
#include "Abwicklungsdreieck.h"
#include "GewichtungsfaktorenReader.h"
#include "Gewichtungsfaktoren.h"
#include "Tarif_Sach.h"
#include "CalculationEngine_Sach.h"
#include "CalculationEngine_Sach_Typ1.h"


#if defined(QL_ENABLE_SESSIONS)
namespace QuantLib {
    Integer sessionId() { return 0; }
}
#endif

using namespace QuantLib;
using namespace SachLib;


int main()
{
    std::cout << "\n\n\nTest Chain-Ladder-Verfahren\n\n";

    std::string input1 = "C:/Users/D91476/Desktop/LifeLib_Sol/awd.csv";
    std::string input2 = "C:/Users/D91476/Desktop/LifeLib_Sol/gwf.csv";


    boost::shared_ptr<PricingEngine> EngineTyp1(new CalculationEngine_Sach_Typ1());

    SachLib::AbwicklungsdreieckReader input1Reader(input1);
    SachLib::GewichtungsfaktorenReader input2Reader(input2);

    SachLib::Abwicklungsdreieck AWD = input1Reader.get_awd();
    std::cout << "\nInput 1: Abwicklungsdreieck\n\n";
    std::cout << AWD.get_Matrix() << "\n";

    SachLib::Gewichtungsfaktoren GWF = input2Reader.get_gwf();
    std::cout << "\nInput 2: Gewichtungsfaktoren\n\n";
    std::cout << GWF.get_Matrix();

    Tarif_Sach *tarifsach1;
    tarifsach1 = new Tarif_Sach_Typ1(AWD, GWF);

    tarifsach1->setPricingEngine(EngineTyp1);
    EngineTyp1->calculate();
}
AWDCalculator.cpp

#include "AWDCalculator.h"


SachLib::AWDCalculator::AWDCalculator()
{
}

SachLib::AWDCalculator::AWDCalculator(Tarif_Sach::arguments *arguments)
    : AWDCalculator(arguments->awd, arguments->gwf)
{
    arguments_ = arguments;
}

SachLib::AWDCalculator::AWDCalculator(Abwicklungsdreieck awd, Gewichtungsfaktoren gwf)
    : awd_(awd),
    gwf_(gwf)
{
    results_ = new AWDCalculator(awd, gwf);
    calculate(awd, gwf);
}

SachLib::AWDCalculator::AWDCalculator(const AWDCalculator& obj)
{
    arguments_ = obj.arguments_;
    awd_ = obj.awd_;
    gwf_ = obj.gwf_;
}

SachLib::AWDCalculator& SachLib::AWDCalculator::operator=(AWDCalculator const& rhs)
{
    arguments_ = rhs.arguments_;
    awd_ = rhs.awd_;
    gwf_ = rhs.gwf_;

    return *this;
}


void SachLib::AWDCalculator::update(Tarif_Sach::arguments *arguments)
{
    results_ = new AWDCalculator(arguments);
    arguments_ = arguments;
    awd_ = arguments->awd;
    gwf_ = arguments->gwf;
}

void SachLib::AWDCalculator::calculate(Abwicklungsdreieck awd, Gewichtungsfaktoren gwf)
{
    // RSB_, RSB_all_ and estimated_costs_matrix_ get calculated here with the input awd and gwf
}

inline const Matrix& SachLib::AWDCalculator::estimated_costs_matrix() const
{
    return estimated_costs_matrix_;
}

inline const Matrix& SachLib::AWDCalculator::RSB_all() const
{
    return RSB_all_;
}

inline const Matrix& SachLib::AWDCalculator::RSB() const
{
    return RSB_;
}

inline const SachLib::Abwicklungsdreieck& SachLib::AWDCalculator::awd() const
{
    return awd_;
}

inline const SachLib::Gewichtungsfaktoren& SachLib::AWDCalculator::gwf() const
{
    return gwf_;
}
计算引擎

#pragma once

#ifndef SachLib_calculationengine_sach_hpp
#define SachLib_calculationengine_sach_hpp

#include "Tarif_Sach.h"
#include "AWDCalculator.h"

using namespace QuantLib;

namespace SachLib {

    class CalculationEngine_Sach : public Tarif_Sach::engine {
    public:
        CalculationEngine_Sach();
        void calculate() const;

    protected:
        mutable boost::shared_ptr<AWDCalculator> AWDCalculator_;

        void set_results(boost::shared_ptr<AWDCalculator> &awdCalculator) const;

    };

}

#endif
计算引擎类型1.cpp

#include "CalculationEngine_Sach_Typ1.h"

SachLib::CalculationEngine_Sach_Typ1::CalculationEngine_Sach_Typ1()
{}

如果有人能帮忙,我将不胜感激。

您需要找到包含“矩阵”定义的include文件,这就是错误显示的内容。

您在
.cpp
中标记了该函数
内联

inline const Matrix& SachLib::AWDCalculator::RSB() const
在这种情况下,编译器不必生成越位定义,除非该翻译单元中需要它(例如,取函数地址)。这会导致链接器错误


从函数定义中删除
inline
,使编译器生成一个越行定义来修复链接器错误。

inline
方法应该在头本身中实现。QuantLib是什么?哦,对不起,忘了写,QuantLib是用于评估金融工具的名称空间。我想创建我自己的工具。这将是一个预处理器/编译器错误,虽然这是链接错误,但是现在我得到了一个运行时错误:在Me.EXE中0x000的FF78D7F59E08中抛出异常:微软C++异常:STD::运行时错误在内存位置0x000 000 B57 27 AEB40。@斯特凡问一个新问题。在我自己尝试过之后,我找不到解决方案,我发布了一个新的问题,可以在这里找到:
#include "CalculationEngine_Sach.h"
#include "Tarif_Sach.h"
#include "AWDCalculator.h"


using namespace QuantLib;

namespace SachLib {

    CalculationEngine_Sach::CalculationEngine_Sach()
    {

    }

    void CalculationEngine_Sach::calculate() const
    {
        arguments_.AWDCalculator->update(&arguments_);

        CalculationEngine_Sach::set_results(arguments_.AWDCalculator);
    }

    void CalculationEngine_Sach::set_results(boost::shared_ptr<AWDCalculator> &awdCalculator) const
    {
        results_.estimated_costs_matrix = awdCalculator->estimated_costs_matrix();
        results_.RSB_all = awdCalculator->RSB_all();
        results_.RSB = awdCalculator->RSB();
        // because of the above three lines the error appears
    }
}
#pragma once
#include "CalculationEngine_Sach.h"

namespace SachLib {
    class CalculationEngine_Sach_Typ1 : public CalculationEngine_Sach
    {
    public:
        CalculationEngine_Sach_Typ1();
    };

}
#include "CalculationEngine_Sach_Typ1.h"

SachLib::CalculationEngine_Sach_Typ1::CalculationEngine_Sach_Typ1()
{}
inline const Matrix& SachLib::AWDCalculator::RSB() const