天天看點

Mac OS X下Qwt安裝

1.QWT

Qwt (http://sourceforge.jp/projects/sfnet_qwt/)is a graphics extension to the Qt GUI application framework from Trolltech AS of Norway. It provides a 2D plotting widget and more.

2.安裝Qwt

a. cd /path/to/qwt

b. qmake

c. make -j 4

d. sudo make install

以上方法會将qwt安裝到/usr/local/qwt-6.1.2

3.測試Qwt是否安裝成功

3.1 LearnQwt

A. LearnQwt.pro

QT +=core gui

include(/usr/local/qwt-6.1.2/features/qwt.prf)

INCLUDEPATH += /usr/local/qwt-6.1.2/lib/qwt.framework/Versions/6/Headers

TARGET = LearnQwt

TEMPLATE = app

SOURCES += \
    main.cxx

LIBS += -F"/usr/local/qwt-6.1.2/lib/qwt.framework"

LIBS += -framework qwt                

B. main.cxx

p, li { white-space: pre-wrap; }
//std
#include <cmath>

//qwt
#include <qwt_series_data.h>
#include <qwt_plot_curve.h>
#include <qwt_plot.h>
#include <qwt_point_data.h>

//qt
#include <QApplication>

class SinusData : public QwtSyntheticPointData
{
public:
  SinusData():
      QwtSyntheticPointData(100)
  {}
  virtual double y(double x) const
  {
      return qSin(x);
  }
};

int main(int argc, char **argv)
{
    QApplication app(argc,argv);

    QwtPlot plot;
    plot.setAxisScale( QwtPlot::xBottom, 0.0, 10.0);
    plot.setAxisScale( QwtPlot::yLeft, -1.0, 1.0);

    QwtPlotCurve *curve = new QwtPlotCurve("y = sin(x)");
    curve->setData(new SinusData());
    curve->attach(&plot);

    plot.show();

    return app.exec();
}                

C. 終端下運作LearnQwt.app

export DYLD_FRAMEWORK_PATH="/usr/local/qwt-6.1.2/lib/"

這點實在無語,和Linux平台的LD_LIBRARY_PATH起着一樣的作用。否則會提示

dyld: Library not loaded: qwt.framework/Versions/6/qwt
           

LearnQwt.app/Contents/MacOS/LearnQwt

D. 運作結果如下:

Mac OS X下Qwt安裝

4.總結。

在PRO檔案中LIBS += -F "/path/to/lib" -framework(f) qwt

include("/path/to/qwt.pri")

export DYLD_FRAMEWORK_PATH="/path/to/lib"

Terminal: ./xxx.app/Contents/MacOS/xxx

版權聲明:本文為CSDN部落客「weixin_33909059」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。

原文連結:https://blog.csdn.net/weixin_33909059/article/details/91998457