Russian Qt Forum
Сентябрь 30, 2024, 22:30 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: Qt+qwt+ubuntu  (Прочитано 3284 раз)
Impuls
Гость
« : Октябрь 08, 2010, 19:35 »

Доброго времени суток уважаемые эксперты. В моем приложении необходимо строить графики функций и гистограммы распределения. Покопавшись в интернете наткнулся на библиотеку qwt. Дабы не заморачиваться с установкой и настройкой последней версии библиотеки установил из репозиториев (у меня ubuntu 10.04) библиотеку 5-й версии. Копнув поглубже нашел простенький пример на Хабре (http://habrahabr.ru/blogs/qt_software/82614/#habracut). Немного подправил файл проекта.
Было:
Код:
TEMPLATE      = app

include(qwt.prf)

unix {
}
win32 {
    LIBS      += -L"D:/mydocs/qt4projects/qt4comp/qwt-5.2.0/lib" -lqwt
}

HEADERS       = QwtBeginner.h

SOURCES       = QwtBeginner.cpp \
                main.cpp
Стало:
Код:
TEMPLATE      = app

LIBS += -lqwt

HEADERS       = QwtBeginner.h

SOURCES       = QwtBeginner.cpp \
                main.cpp
Попытался запустить а вместо программы получаю кучу сообщений типа:
Код:
/home/impuls/QwtBeginner/QwtBeginner.cpp:17: undefined reference to `QwtPlot::QwtPlot(QWidget*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:18: undefined reference to `QwtPlot::QwtPlot(QWidget*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:27: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:28: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:29: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:30: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:32: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:33: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:34: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:35: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:37: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:38: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:39: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:40: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:42: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:43: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:44: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:45: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:64: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:65: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:66: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:67: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:17: undefined reference to `QwtPlot::QwtPlot(QWidget*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:18: undefined reference to `QwtPlot::QwtPlot(QWidget*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:27: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:28: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:29: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:30: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:32: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:33: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:34: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:35: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:37: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:38: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:39: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:40: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:42: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/impuls/QwtBeginner/QwtBeginner.cpp:43: undefined reference to `QwtPlotItem::setRenderHint(QwtPlotItem::RenderHint, bool)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:44: undefined reference to `QwtPlotCurve::setPen(QPen const&)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:45: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:64: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:65: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:66: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
/home/impuls/QwtBeginner/QwtBeginner.cpp:67: undefined reference to `QwtPlotCurve::setData(double const*, double const*, int)'
collect2: ld returned 1 exit status
А вот и сам код:
Код:
//-----------------------------------------------------------------
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
//-----------------------------------------------------------------
#include <qwt-qt4/qwt_plot.h>
#include <qwt-qt4/qwt_plot_curve.h>
//-----------------------------------------------------------------
#include <math.h>
//-----------------------------------------------------------------
#include "QwtBeginner.h"
//-----------------------------------------------------------------
QwtBeginner::QwtBeginner(QWidget *parent):QWidget(parent)
{
    // Create plots
    funPlot = new QwtPlot;
    derPlot = new QwtPlot;

    funPlot->setTitle("Function");
    derPlot->setTitle("Derivative");

    // Create curves and attach them to plots
    QPen sinPen = QPen(Qt::red);
    QPen cubPen = QPen(Qt::blue);

    sinFunCurve = new QwtPlotCurve;
    sinFunCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    sinFunCurve->setPen(sinPen);
    sinFunCurve->attach(funPlot);

    sinDerCurve = new QwtPlotCurve;
    sinDerCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    sinDerCurve->setPen(sinPen);
    sinDerCurve->attach(derPlot);

    cubFunCurve = new QwtPlotCurve;
    cubFunCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    cubFunCurve->setPen(cubPen);
    cubFunCurve->attach(funPlot);

    cubDerCurve = new QwtPlotCurve;
    cubDerCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    cubDerCurve->setPen(cubPen);
    cubDerCurve->attach(derPlot);

    // Set data
    const int N = 20;
    double x[N+1];
    double sinFunData[N+1], sinDerData[N+1];
    double cubFunData[N+1], cubDerData[N+1];
    for (int i = 0; i <= N; ++i)
    {
        const double pi = 4.0 * atan(1.0);
        double L = 2;
        double h = L / N;

        x[i] = -L/2 + i * h;
        sinFunData[i] = sin(x[i] * pi);
        sinDerData[i] = cos(x[i] * pi) * pi;
        cubFunData[i] = x[i] * x[i] * x[i];
        cubDerData[i] = 3 * x[i] * x[i];
    }
    sinFunCurve->setData(x, sinFunData, N+1);
    sinDerCurve->setData(x, sinDerData, N+1);
    cubFunCurve->setData(x, cubFunData, N+1);
    cubDerCurve->setData(x, cubDerData, N+1);

    // Hide curves
    sinFunCurve->setVisible(false);
    sinDerCurve->setVisible(false);

    cubFunCurve->setVisible(false);
    cubDerCurve->setVisible(false);

    // Create buttons
    sinButton = new QPushButton("Sinus"),
    cubButton = new QPushButton("Cubic function"),

    sinButton->setCheckable(true);
    cubButton->setCheckable(true);

    // Connect signals
    connect(sinButton, SIGNAL(toggled(bool)), this, SLOT(sinToggled(bool)));
    connect(cubButton, SIGNAL(toggled(bool)), this, SLOT(cubToggled(bool)));

    // Set layouts
    QHBoxLayout *plotsLayout = new QHBoxLayout;
    plotsLayout->setSpacing(10);
    plotsLayout->addWidget(funPlot);
    plotsLayout->addWidget(derPlot);

    QHBoxLayout *buttonsLayout = new QHBoxLayout ;
    buttonsLayout->addWidget(sinButton);
    buttonsLayout->addWidget(cubButton);

    QVBoxLayout *widgetLayout = new QVBoxLayout;
    widgetLayout->addLayout(plotsLayout);
    widgetLayout->addLayout(buttonsLayout);

    setLayout(widgetLayout);
    showMaximized();
}
//-----------------------------------------------------------------
void QwtBeginner::sinToggled(bool checked)
{
    sinFunCurve->setVisible(checked);
    sinDerCurve->setVisible(checked);
    funPlot->replot();
    derPlot->replot();
}
//-----------------------------------------------------------------
void QwtBeginner::cubToggled(bool checked)
{
    cubFunCurve->setVisible(checked);
    cubDerCurve->setVisible(checked);
    funPlot->replot();
    derPlot->replot();
}
//-----------------------------------------------------------------
Собственно хотелось бы узнать причину такой ненависти компилятора к данной библиотеке)))
Расскажите что я не так делаю, и, если можно, помогите примерами пользования данной библиотекой (ибо под 5 версию я экземплов не нашел)
Заранее спасибо за помощь.
З.Ы. Извиняюсь что такое обширное сообщение: не нашел как вставлять спойлеры.
Записан
eugene
Гость
« Ответ #1 : Октябрь 09, 2010, 11:31 »

Цитировать
unix {
}
win32 {
    LIBS      += -L"D:/mydocs/qt4projects/qt4comp/qwt-5.2.0/lib" -lqwt
}

Мб попробовать прописать путь до библы в блоке unix?
Записан
Impuls
Гость
« Ответ #2 : Октябрь 09, 2010, 11:56 »

Мб попробовать прописать путь до библы в блоке unix?
Практически ничего не меняется. Исчезли все варнинги, но ошибка осталась:
Код:
:-1: error: collect2: ld returned 1 exit status
Писал так:
Код:
LIBS += /usr/lib -lqwt
Записан
eugene
Гость
« Ответ #3 : Октябрь 09, 2010, 13:37 »

А консоль сборки можно посмотреть? Там обычно можно увидеть конкретную ошибку.
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.1 секунд. Запросов: 20.