• 8355阅读
  • 6回复

【提问】tmake產生makefile [复制链接]

上一主题 下一主题
离线btopcst
 
只看楼主 倒序阅读 楼主  发表于: 2005-10-28
環境:qt-embedded-2.3.7
/////////////////////////////////////////////////////////////////////////////////
hello.pro內容:

TEMPLATE     = app
CONFIG         += qt warn_on release
HEADERS         = hello.h
SOURCES         = hello.cpp \
          main.cpp
TARGET         = hello
DEPENDPATH=../../include
REQUIRES=

/////////////////////////////////////hello.h///////////////////////////////////////
#ifndef HELLO_H
#define HELLO_H

#include <qwidget.h>


class Hello : public QWidget
{
  Q_OBJECT
public:
  Hello( const char *text, QWidget *parent=0, const char *name=0 );
signals:
  void clicked();
protected:
  void mouseReleaseEvent( QMouseEvent * );
  void paintEvent( QPaintEvent * );
private slots:
  void animate();
private:
  QString t;
  int   b;
};

#endif
/////////////////////hello.cpp//////////////////////////////
#include "hello.h"
#include <qpushbutton.h>
#include <qtimer.h>
#include <qpainter.h>
#include <qpixmap.h>


/*
Constructs a Hello widget. Starts a 40 ms animation timer.
*/

Hello::Hello( const char *text, QWidget *parent, const char *name )
  : QWidget(parent,name), t(text), b(0)
{
  QTimer *timer = new QTimer(this);
  connect( timer, SIGNAL(timeout()), SLOT(animate()) );
  timer->start( 40 );

  resize( 260, 130 );
}


/*
This private slot is called each time the timer fires.
*/

void Hello::animate()
{
  b = (b + 1) & 15;
  repaint( FALSE );
}


/*
Handles mouse button release events for the Hello widget.

We emit the clicked() signal when the mouse is released inside
the widget.
*/

void Hello::mouseReleaseEvent( QMouseEvent *e )
{
  if ( rect().contains( e->pos() ) )
    emit clicked();
}


/*
Handles paint events for the Hello widget.

Flicker-free update. The text is first drawn in the pixmap and the
pixmap is then blt'ed to the screen.
*/

void Hello::paintEvent( QPaintEvent * )
{
  static int sin_tbl[16] = {
    0, 38, 71, 92, 100, 92, 71, 38,     0, -38, -71, -92, -100, -92, -71, -38};

  if ( t.isEmpty() )
    return;

  // 1: Compute some sizes, positions etc.
  QFontMetrics fm = fontMetrics();
  int w = fm.width(t) + 20;
  int h = fm.height() * 2;
  int pmx = width()/2 - w/2;
  int pmy = height()/2 - h/2;

  // 2: Create the pixmap and fill it with the widget's background
  QPixmap pm( w, h );
  pm.fill( this, pmx, pmy );

  // 3: Paint the pixmap. Cool wave effect
  QPainter p;
  int x = 10;
  int y = h/2 + fm.descent();
  int i = 0;
  p.begin( &pm );
  p.setFont( font() );
  while ( !t.isNull() ) {
    int i16 = (b+i) & 15;
    p.setPen( QColor((15-i16)*16,255,255,QColor::Hsv) );
    p.drawText( x, y-sin_tbl[i16]*h/800, t.mid(i,1), 1 );
    x += fm.width( t );
    i++;
  }
  p.end();

  // 4: Copy the pixmap to the Hello widget
  bitBlt( this, pmx, pmy, &pm );
}
/////////////////////////main.cpp///////////////////////
#include "hello.h"
#include <qapplication.h>

int main( int argc, char **argv )
{
  QApplication a(argc,argv);
  QString s;
  for ( int i=1; i<argc; i++ ) {
    s += argv;
    if ( i<argc-1 )
      s += " ";
  }
  if ( s.isEmpty() )
    s = "Hello, World";
  Hello h( s );
  h.setCaption( "Qt says hello" );
  QObject::connect( &h, SIGNAL(clicked()), &a, SLOT(quit()) );
  h.setFont( QFont("times",32,QFont::Bold) );         // default font
  h.setBackgroundColor( Qt::white );               // default bg color
  a.setMainWidget( &h );
  h.show();
  return a.exec();
}


/////////////////////make後的訊息///////////////////////////////
hello.o(.text+0x16): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QWidget::QWidget[not-in-charge](QWidget*, char const*, unsigned)'
hello.o(.text+0x31): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QString::QString[in-charge](char const*)'
hello.o(.text+0x52): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QTimer::QTimer[in-charge](QObject*, char const*)'
hello.o(.text+0x66): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QObject::connect(QObject const*, char const*, QObject const*, char const*)'
hello.o(.text+0x73): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QTimer::start(int, bool)'
hello.o(.text+0x86): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QWidget::resize(int, int)'
hello.o(.text+0xb9): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QString::shared_null'
hello.o(.text+0xc9): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QStringData::deleteSelf()'
hello.o(.text+0xd4): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QString::shared_null'
hello.o(.text+0xeb): In function `Hello::Hello[not-in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QWidget::~QWidget [not-in-charge]()'
hello.o(.text+0x10e): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QWidget::QWidget[not-in-charge](QWidget*, char const*, unsigned)'
hello.o(.text+0x129): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QString::QString[in-charge](char const*)'
hello.o(.text+0x14a): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QTimer::QTimer[in-charge](QObject*, char const*)'
hello.o(.text+0x15e): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QObject::connect(QObject const*, char const*, QObject const*, char const*)'
hello.o(.text+0x16b): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QTimer::start(int, bool)'
hello.o(.text+0x17e): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QWidget::resize(int, int)'
hello.o(.text+0x1b1): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QString::shared_null'
hello.o(.text+0x1c1): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QStringData::deleteSelf()'
hello.o(.text+0x1cc): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
: undefined reference to `QString::shared_null'
hello.o(.text+0x1e3): In function `Hello::Hello[in-charge](char const*, QWidget*, char const*)':
//////////////我的問題///////////////////////////////////////
這是qt-2.3.7裡的範例…如果利用範例的makefile來make的話…

確定可以過…但是我用tmake -o Makefile hello.pro來產生makefile…

做make…他不能過…訊息如上…各位高手…如果知道原因…能否

告訴我…麻煩大家…謝謝
[ 此贴被fanyu在2005-10-29 10:44重新编辑 ]
离线angusliu

只看该作者 1楼 发表于: 2005-10-30
确认环境变量是否设置正确,如TMAKEDIR,TMAKEPATH

我用qt-2.3.7时,编译应用程序喜欢用如下这种步骤编译:)
qmake -project
tmake -o Makefile hello.pro
make
离线btopcst
只看该作者 2楼 发表于: 2005-11-01
下面是引用angusliu于2005-10-30 22:37发表的:
确认环境变量是否设置正确,如TMAKEDIR,TMAKEPATH
我用qt-2.3.7时,编译应用程序喜欢用如下这种步骤编译:)
qmake -project
tmake -o Makefile hello.pro
.......


我的環境變數:
export QTDIR=/root/qt-2.3.7
export TMAKEDIR=/root/tmake-1.13
export TMAKEPATH=/root/tmake-1.13/lib
執行動作:
cd qt-2.3.7/examples/hello
qmake -project
tmake -o Makefile hello.pro
make


請問一下…我有那些動作有問題…能否指教一下…謝謝
离线youngki
只看该作者 3楼 发表于: 2005-11-01
环境里没有加入相应的库,应该是这样
知识和财富,只在流通中产生价值
离线btopcst
只看该作者 4楼 发表于: 2005-11-01
下面是引用youngki于2005-11-01 20:27发表的:
环境里没有加入相应的库,应该是这样

什麼意思…我不懂…你指的是qt的lib嗎??

那是要export那個參數…能否告知…謝謝
离线youngki
只看该作者 5楼 发表于: 2005-11-02
qt/e的lib
export LD_LIBARARY_PATH =......
知识和财富,只在流通中产生价值
离线angusliu

只看该作者 6楼 发表于: 2005-11-02
export QTEDIR=
export QTDIT=$QTEDIR
export LD_LIBRARY_PAQTH=
export PATH=
export TMAKEDIR=
export TMAKEPATH=
网上有很多文档提到,自己找找
快速回复
限100 字节
 
上一个 下一个