PDA

View Full Version : QuantLib



Arend
15th March 2013, 09:02
Hello,

I want to make use of QuantLib, especially for converting a date into a serialnumber.
When I run the program below I get the error:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall QuantLib::Date::Date(int,enum QuantLib::Month,int)" (??0Date@QuantLib@@QAE@HW4Month@1@H@Z) referenced in function "private: class QuantLib::Date __thiscall MainWindow::date1(void)const " (?date1@MainWindow@@ABE?AVDate@QuantLib@@XZ)

I tried a lot, but still can't figure it out.
Can someone give me a hint?

Regards,
Arend

My .pro file:

QT += core gui
INCLUDEPATH += . C:/Libs/boost_1_46_1 C:/Libs/QuantLib-1.1
LIBS += -LC:/Libs/QuantLib-1.1/lib
TARGET = testQuantLib
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui


My .h file

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <ql/time/date.hpp>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private:
Ui::MainWindow *ui;
QuantLib::Date date1() const;
};
#endif // MAINWINDOW_H

Mu .cpp file:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QuantLib::Date dateOld=this->date1();
}

MainWindow::~MainWindow()
{
delete ui;
}

QuantLib::Date MainWindow::date1() const {
QDate date=ui->curveDate->date();
QuantLib::Date d(date.day(),(QuantLib::Month)date.month(),date.ye ar());
return d;
}

Added after 23 minutes:

I solved it: added #include <ql/auto_link.hpp> somewhere in the program.

Arend
17th March 2013, 09:19
I solved it: added #include <ql/auto_link.hpp> somewhere in the program.