Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: undefined reference  (Read 4540 times)

rquiterio

  • Newbie
  • *
  • Posts: 3
    • View Profile
undefined reference
« on: August 22, 2016, 08:50:17 pm »
Hello,
I'm trying to run a simple Lime report.

 This is the .pro file
QT       += core gui sql printsupport xml script

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = limeReportTest01
TEMPLATE = app



SOURCES += main.cpp\
        limemain.cpp

HEADERS  += limemain.h

FORMS    += limemain.ui

INCLUDEPATH += "C:\programas\LimeReport-master_1311\limereport"

This is the header file:
#ifndef LIMEMAIN_H
#define LIMEMAIN_H

#include <QMainWindow>
#include <QtSql>
#include <QSqlDatabase>
#include <QDebug>
#include <QMessageBox>
#include <QSqlQuery>
#include "lrreportengine.h"
#include "lrcallbackdatasourceintf.h"

namespace Ui {
class limeMain;
}

class limeMain : public QMainWindow
{
    Q_OBJECT

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

private slots:
    void on_pushButton_clicked();

private:
    Ui::limeMain *ui;
    LimeReport::ReportEngine *report;
};

#endif // LIMEMAIN_H

And the .cpp file:

#include "limemain.h"
#include "ui_limemain.h"
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord>
#include "lrreportengine.h"
#include "lrcallbackdatasourceintf.h"

limeMain::limeMain(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::limeMain)
{
    ui->setupUi(this);

    QSqlDatabase db;
    db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("localhost");
    db.setPort(5432);
    db.setDatabaseName("db");
    db.setUserName("postgres");
    db.setPassword("postgres");
    db.open();
    if (!db.open())
    {
        QMessageBox::critical(0, QObject::tr("Database Error"), db.lastError().text());
    }
    else
    {
        qDebug()<<"Conexion ok";
    }
}

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

void limeMain::on_pushButton_clicked()
{

    report = new LimeReport::ReportEngine(this);

    report->dataManager()->addModel("string_list",stringListModel,true);
    report->loadFromFile("File path");
    report->previewReport();
    //report->printReport();

}


But when i compile, it keeps giving me this error:
C:\qprogramacion\limeReportTest01\limemain.cpp:40: error: undefined reference to `LimeReport::ReportEngine::ReportEngine(QObject*)'

What is missing?

Thanks in advance.


Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: undefined reference
« Reply #1 on: August 23, 2016, 08:22:22 pm »
Hi

1. You should build limereport as shared library
2. Connect it to your application. Example:
in your pro file write something like this
Code: [Select]

    INCLUDEPATH += "C:\programas\LimeReport-master_1311\limereport\build\5.6.0\release\lib\include"
    LIBS += -L"C:\programas\LimeReport-master_1311\limereport\build\5.6.0\release\lib" -llimereport

rquiterio

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: undefined reference
« Reply #2 on: August 23, 2016, 10:21:10 pm »
That solved the situation.

Thanks a lot!