2017-11-03 19 views
1

을 연결하면 나는 다음과 같은 오류 얻을 :어려움 ++/내 코드를 컴파일 할 때 오류

LNK2019 unresolved external symbol "public: class QuantLib::Matrix const & __cdecl SachLib::AWDCalculator::RSB(void)const " ([email protected]@[email protected]@[email protected]@@XZ) referenced in function "protected: void __cdecl SachLib::CalculationEngine_Sach::set_results(class boost::shared_ptr &)const " ([email protected][email protected]@@[email protected]@[email protected]@@[email protected]@@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(); 
} 

:

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

AWDCalculator.h

#pragma once 

#include "Tarif_Sach.h" 
#include "Abwicklungsdreieck.h" 
#include "Gewichtungsfaktoren.h" 

#ifndef _AWDCalculator_H 
#define _AWDCalculator_H 

namespace SachLib { 

    class AWDCalculator { 
    public: 
     AWDCalculator(); 
     AWDCalculator(Tarif_Sach::arguments *arguments); 
     AWDCalculator(Abwicklungsdreieck awd, Gewichtungsfaktoren gwf); 
     AWDCalculator(const AWDCalculator &obj); 
     AWDCalculator& operator=(AWDCalculator const& rhs); 


     //! Fills vectors. 
     void update(Tarif_Sach::arguments *arguments); 

     // Logic 
     void calculate(Abwicklungsdreieck awd, Gewichtungsfaktoren gwf); 

     //! \name Getter 
     //@{ 
     const Abwicklungsdreieck& awd() const; 
     const Gewichtungsfaktoren& gwf() const; 
     const Matrix& estimated_costs_matrix() const; 
     const Matrix& RSB_all() const; 
     const Matrix& RSB() const; 
     //@} 

     Tarif_Sach::arguments *arguments_; 

    protected: 
     AWDCalculator *results_; 
     Abwicklungsdreieck awd_; 
     Gewichtungsfaktoren gwf_; 

     //! \name Outputs 
     //@{ 
     Matrix estimated_costs_matrix_; 
     Matrix RSB_all_; 
     Matrix RSB_; 
     //@} 

    }; 

} 

#endif 

AWDCalculator.cpp

CalculationEngine_Sach.h

#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 

CalculationEngine_Sach.cpp

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

CalculationEngine_Sach_Typ1.h

#pragma once 
#include "CalculationEngine_Sach.h" 

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

} 

CalculationEngine_Sach_Typ1.cpp

#include "CalculationEngine_Sach_Typ1.h" 

SachLib::CalculationEngine_Sach_Typ1::CalculationEngine_Sach_Typ1() 
{} 
01,

누구든지 도와 주시면 감사하겠습니다.

+2

'inline' 메소드는 헤더 자체에 구현되어야합니다. –

+0

QuantLib이란 무엇입니까? –

+0

오, 죄송합니다. 작성을 잊어 버렸습니다. QuantLib은 금융 상품을 평가하기위한 네임 스페이스입니다. 나만의 악기를 만들고 싶다. –

답변

1

당신은 .cpp에 그 기능 inline 표시 :이 경우

inline const Matrix& SachLib::AWDCalculator::RSB() const 

컴파일러가 그 번역 단위에 필요하지 않은 경우, 아웃 - 오브 - 라인 정의를 생성 할 필요가 없습니다 (예를 들어, 함수 주소 촬영됩니다. 그리고 그 때문에 링커 오류가 발생합니다.

컴파일러에서 라인 외부 정의를 생성하여 링커 오류를 수정하도록하려면 함수 정의에서 inline을 제거하십시오.

+0

고맙습니다. –

+0

그래도 런타임 오류가 발생합니다. 예외는 main.exe의 0x00007FF8D7F59E08에서 발생합니다. Microsoft C++ 예외 : 메모리 위치 0x000000B5727AEB40의 std :: runtime_error. –

+0

@Stefan 새로운 질문이 있습니다. –

-2

"매트릭스"에 대한 정의가있는 포함 파일을 찾아야합니다. 이것이 바로 오류입니다.

+0

이것은 전처리 기/컴파일러 오류 일 수 있지만 링커 오류입니다. –

+0

http://quantlib.org/reference/class_quant_lib_1_1_matrix.html –