在Mac OSX 10.7.4上编译简单的Qwt程序时出错 [英] Error when compiling simple Qwt program on Mac OSX 10.7.4

查看:523
本文介绍了在Mac OSX 10.7.4上编译简单的Qwt程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Qwt v。6.0.1来获得下面的c ++程序:

  #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();
}

且.pro档案如下:

  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

但是,当我现在尝试做



qmake



b
$ b

我得到错误:



ld:没有为-lqwt找到库
collect2:ld返回1退出状态
make: * [qwtTest.app/Contents/MacOS/qwtTest]错误1



非常感谢任何帮助。

解决方案

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

。由于Mac OS X框架的命名约定,qwt.framework中的动态库不命名为libqwt.dylib(链接器需要它),而只是qwt。
使用

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


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.

解决方案

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.

这篇关于在Mac OSX 10.7.4上编译简单的Qwt程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆