Mikey
Mikey

Reputation: 13

Error when compiling simple Qwt program on Mac OSX 10.7.4

I'm trying to get the following c++ program using Qwt v. 6.0.1 to work:

#include <cmath>
#include <QApplication>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>

int main(int argc, char **argv)
{
   QApplication a(argc, argv);
   QwtPlot plot(QwtText("CppQwtExample1"));
   plot.setGeometry(0,0,640,400);
   plot.setAxisScale(QwtPlot::xBottom, 0.0, 2.0*M_PI);
   plot.setAxisScale(QwtPlot::yLeft, -1.0, 1.0);

   QwtPlotCurve sine("Sine");
   std::vector<double> xs;
   std::vector<double> ys;
   for (double x=0; x<2.0*M_PI; x+=(M_PI/10.0)) {
      xs.push_back(x);
      ys.push_back(std::sin(x));
   }
   sine.setData(&xs[0], &ys[0], xs.size());
   sine.attach(&plot);

   plot.show();
   return a.exec();
}

and the .pro file looks like:

TEMPLATE = app
TARGET = CppQwtExample1
QMAKEFEATURES += /usr/local/qwt-6.0.1/features
CONFIG += qwt
INCLUDEPATH += /usr/local/qwt-6.0.1/lib/qwt.framework/Headers
LIBS += -L/usr/local/qwt-6.0.1/lib/qwt.framework/Versions/6/ \
 -lqwt
SOURCES += qwtTest.cpp

However, when I now try to do

qmake

make

I get the error:

ld: library not found for -lqwt collect2: ld returned 1 exit status make: * [qwtTest.app/Contents/MacOS/qwtTest] Error 1

I surely miss something here. Any help is greatly appreciated.

Upvotes: 1

Views: 1978

Answers (1)

user529758
user529758

Reputation:

LIBS += -L/usr/local/qwt-6.0.1/lib/qwt.framework/Versions/6/ -lqwt

This is wrong. Due to the naming conventions of Mac OS X frameworks, the dynamic library inside qwt.framework isn't named "libqwt.dylib" (which the linker requires), but simply "qwt". Use

LIBS += -F/usr/local/qwt-6.0.1/lib -framework qwt

instead.

Upvotes: 2

Related Questions