Error when compiling simple Qwt program on Mac OSX 10.7.4

拜拜、爱过 提交于 2019-12-10 11:40:12

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10540666/error-when-compiling-simple-qwt-program-on-mac-osx-10-7-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!