天嵌 ARM开发社区

 找回密码
 注册
查看: 3979|回复: 11

QT教程中,关于第一个first程序开发的过程最后编译出错,悬赏求解

[复制链接]
zsagan 发表于 2012-6-12 18:23:01 | 显示全部楼层 |阅读模式
5
本帖最后由 zsagan 于 2012-6-13 18:20 编辑

[root@EmbedSky first]# make
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include -o first.o first.cpp
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include -o main.o main.cpp
main.cpp:3:36: qtopia/qpeapplicationl.h: 没有那个文件或目录
main.cpp:5: parse error before `)' token
main.cpp:6: ISO C++ forbids declaration of `QTOPIA_ADD_APPLICATION' with no
   type
main.cpp:6: initializer list being treated as compound expression
main.cpp:6: syntax error at end of input
make: *** [main.o] Error 1


请问这是什么原因导致的,怎么解决呢
下面是开始自动生成的Makefile文件:
#############################################################################
# Makefile for building first
# Generated by tmake at 17:52, 2011/10/16
#     Project: first
#    Template: app
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
CFLAGS = -pipe -Wall -W -O2 -DNO_DEBUG
CXXFLAGS= -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG
INCPATH = -I$(QTDIR)/include -I$(QPEDIR)/include
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS) -L$(QPEDIR)/lib -L$(QTDIR)/lib -lqpe -lqtopia -lqte
MOC = $(QTDIR)/bin/moc
UIC = $(QTDIR)/bin/uic
TAR = tar -cf
GZIP = gzip -9f
####### Files
HEADERS = first.h
SOURCES = first.cpp \
  main.cpp
OBJECTS = first.o \
  main.o \
  first.o
INTERFACES = first.ui
UICDECLS = first.h
UICIMPLS = first.cpp
SRCMOC = moc_first.cpp \
  moc_first.cpp

OBJMOC = moc_first.o \
  moc_first.o

DIST =
TARGET = first




INTERFACE_DECL_PATH = .
####### Implicit rules
.SUFFIXES: .cpp .cxx .cc .C .c
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
####### Build rules

all: $(TARGET)


$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
moc: $(SRCMOC)
tmake: Makefile
Makefile: first.pro
tmake first.pro -o Makefile
dist:
$(TAR) first.tar first.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
$(GZIP) first.tar
clean:
-rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
-rm -f *~ core
####### Sub-libraries

###### Combined headers

####### Compile
first.o: first.cpp \
  first.h \
  first.ui
main.o: main.cpp \
  first.h \
  /opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include/qtopia/qpeapplication.h
first.h: first.ui
$(UIC) first.ui -o $(INTERFACE_DECL_PATH)/first.h
first.cpp: first.ui
$(UIC) first.ui -i first.h -o first.cpp
first.o: first.cpp \
  first.h \
  first.ui

moc_first.o: moc_first.cpp \
  first.h

moc_first.o: moc_first.cpp \
  first.h
moc_first.cpp: first.h
$(MOC) first.h -o moc_first.cpp

moc_first.cpp: first.h
$(MOC) first.h -o moc_first.cpp

下面是修改之后的Makefile文件:做修改的地方用红色标出了已经
#############################################################################
# Makefile for building first
# Generated by tmake at 12:02, 2011/10/15
#     Project: first
#    Template: app
#############################################################################

####### Compiler, tools and options

CC      =       gcc
CXX     =       g++
CFLAGS  =       -pipe -Wall -W -O2 -DNO_DEBUG
CXXFLAGS=       -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG
INCPATH =       -I$(QTDIR)/include -I$(QPEDIR)/include
LINK    =       g++
LFLAGS  =
LIBS    =       $(SUBLIBS) -L$(QPEDIR)/lib -L$(QTDIR)/lib -lqpe -lqtopia -lqte
MOC     =       $(QTDIR)/bin/moc
UIC     =       $(QTDIR)/bin/uic

TAR     =       tar -cf
GZIP    =       gzip -9f

####### Files

HEADERS =       first.h
SOURCES =       first.cpp \
                main.cpp
OBJECTS =       first.o \
                main.o \

INTERFACES =    first.ui
UICDECLS =      first.h
UICIMPLS =      first.cpp
SRCMOC  =       moc_first.cpp
OBJMOC  =       moc_first.o
DIST    =
TARGET  =       $(QPEDIR)/image/opt/Qtopia/bin/first
DESKTOP=        $(QPEDIR)/image/opt/Qtopia/apps/Embedsky/first.desktop
ICON=           $(QPEDIR)/image/opt/Qtopia/pics/first.png
INTERFACE_DECL_PATH = .

####### Implicit rules

.SUFFIXES: .cpp .cxx .cc .C .c

.cpp.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cxx.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cc.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.C.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.c.o:
        $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

####### Build rules


all: $(TARGET)
       cp -f first.desktop $(DESKTOP)
        cp -f first.png $(ICON)
$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)

moc: $(SRCMOC)

tmake: Makefile

Makefile: first.pro
        tmake first.pro -o Makefile

dist:
        $(TAR) first.tar first.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
        $(GZIP) first.tar

clean:
        -rm -f $(OBJECTS) $(OBJMOC) $(DESKTOP) $(ICON) $(TARGET)
        -rm -f *~ core

####### Sub-libraries


###### Combined headers


####### Compile

first.o: first.cpp \
                first.h \
                first.ui

main.o: main.cpp \
                first.h \
                /opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include/qtopia/qpeapplication.h

first.h: first.ui
        $(UIC) first.ui -o $(INTERFACE_DECL_PATH)/first.h

first.cpp: first.ui
        $(UIC) first.ui -i first.h -o first.cpp


moc_first.o: moc_first.cpp \
                first.h

moc_first.cpp: first.h
        $(MOC) first.h -o moc_first.cpp






下面是一开始自动生成的first.cpp(没修改之前的):
/****************************************************************************
** Form implementation generated from reading ui file 'first.ui'
**
** Created: 鏃?10鏈?16 17:41:23 2011
**      by: The User Interface Compiler ($Id: qt/main.cpp   3.1.1   edited Nov 21 17:40 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "first.h"
#include <qvariant.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
*  Constructs a first as a child of 'parent', with the
*  name 'name' and widget flags set to 'f'.
*/
first::first( QWidget* parent, const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    if ( !name )
setName( "first" );
    user_b = new QPushButton( this, "user_b" );
    user_b->setGeometry( QRect( 120, 20, 111, 51 ) );
    user_t = new QLabel( this, "user_t" );
    user_t->setGeometry( QRect( 70, 90, 210, 50 ) );
    QFont user_t_font(  user_t->font() );
    user_t_font.setPointSize( 18 );
    user_t_font.setBold( TRUE );
    user_t->setFont( user_t_font );
    close = new QPushButton( this, "close" );
    close->setGeometry( QRect( 240, 150, 90, 32 ) );
    languageChange();
    resize( QSize(600, 480).expandedTo(minimumSizeHint()) );
    // signals and slots connections
    connect( user_b, SIGNAL( clicked() ), this, SLOT( user_button() ) );
    connect( close, SIGNAL( clicked() ), this, SLOT( close() ) );
}
/*
*  Destroys the object and frees any allocated resources
*/
first::~first()
{
    // no need to delete child widgets, Qt does it all for us
}
/*
*  Sets the strings of the subwidgets using the current
*  language.
*/
void first::languageChange()
{
    setCaption( tr( "EmbedSky_First_QT_Program" ) );
    user_b->setText( tr( "User Button" ) );
    user_t->setText( QString::null );
    close->setText( tr( "Close" ) );
}
void first::user_button()
{
    qWarning( "first::user_button(): Not implemented yet" );
}

下面是修改之后的:
/****************************************************************************
** Form implementation generated from reading ui file 'first.ui'
**
** Created: 鏃?10鏈?16 18:34:11 2011
**      by: The User Interface Compiler ($Id: qt/main.cpp   3.1.1   edited Nov 21 17:40 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "first.h"
#include <qvariant.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
*  Constructs a first as a child of 'parent', with the
*  name 'name' and widget flags set to 'f'.
*/
first::first( QWidget* parent, const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    if ( !name )
setName( "first" );
    user_b = new QPushButton( this, "user_b" );
    user_b->setGeometry( QRect( 120, 20, 111, 51 ) );
    user_t = new QLabel( this, "user_t" );
    user_t->setGeometry( QRect( 70, 90, 210, 50 ) );
    QFont user_t_font(  user_t->font() );
    user_t_font.setPointSize( 18 );
    user_t_font.setBold( TRUE );
    user_t->setFont( user_t_font );
    close = new QPushButton( this, "close" );
    close->setGeometry( QRect( 240, 150, 90, 32 ) );
    languageChange();
    resize( QSize(600, 480).expandedTo(minimumSizeHint()) );
    // signals and slots connections
    connect( user_b, SIGNAL( clicked() ), this, SLOT( user_button() ) );
    connect( close, SIGNAL( clicked() ), this, SLOT( close() ) );
}
/*
*  Destroys the object and frees any allocated resources
*/
first::~first()
{
    // no need to delete child widgets, Qt does it all for us
}
/*
*  Sets the strings of the subwidgets using the current
*  language.
*/
void first::languageChange()
{
    setCaption( tr( "EmbedSky_First_QT_Program" ) );
    user_b->setText( tr( "User Button" ) );
    user_t->setText( QString::null );
    close->setText( tr( "Close" ) );
}
void first::user_button()
{
    user_t->setText(tr("Hello,Qt Application!!"));
    //qWarning( "first::user_button(): Not implemented yet" );
}





embedsky_lhh 发表于 2012-6-13 11:29:59 | 显示全部楼层
建议贴下代码,方便大家回复
回复

使用道具 举报

 楼主| zsagan 发表于 2012-6-13 18:21:32 | 显示全部楼层
自己定一个吧,防止沉了
回复

使用道具 举报

 楼主| zsagan 发表于 2012-6-13 18:26:03 | 显示全部楼层
embedsky_lhh 发表于 2012-6-13 11:29
建议贴下代码,方便大家回复

代码已经贴出,帮忙看下,谢谢
回复

使用道具 举报

TQ-lkp 发表于 2012-6-14 09:06:19 | 显示全部楼层
本帖最后由 TQ-lkp 于 2012-6-14 09:07 编辑

g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include -o first.o first.cpp

都不是交叉编绎的

x86的程序是编绎x86的qt环境才能使用
回复

使用道具 举报

 楼主| zsagan 发表于 2012-6-14 13:32:13 | 显示全部楼层
TQ-lkp 发表于 2012-6-14 09:06
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia- ...

我这一个是想在X86上模拟运行,不想在开发板上运行
回复

使用道具 举报

TQ-lkp 发表于 2012-6-14 14:07:54 | 显示全部楼层
那你x86的开发环境有没有建立?
回复

使用道具 举报

 楼主| zsagan 发表于 2012-6-14 21:54:44 | 显示全部楼层
TQ-lkp 发表于 2012-6-14 14:07
那你x86的开发环境有没有建立?

我是按照配套说明书上一步步做的啊,说明书上可以的啊,我的怎么会不行呢?能帮忙传下最新的tq2440的QT教程吗?zsagan@qq.com,谢谢
回复

使用道具 举报

TQ-lkp 发表于 2012-6-15 18:40:05 | 显示全部楼层
手册上的关于x86的环境是不对的,你从qt官网重新下载编绎
回复

使用道具 举报

SiJianH 发表于 2012-8-2 14:30:08 | 显示全部楼层
TQ-lkp 发表于 2012-6-15 18:40
手册上的关于x86的环境是不对的,你从qt官网重新下载编绎

在哪里??
回复

使用道具 举报

yuki 发表于 2012-8-12 12:48:59 | 显示全部楼层
SiJianH 发表于 2012-8-2 14:30
在哪里??

我使用QT2是可以编译成功的,X86环境没问题的。
不过手册上有个错误:
first.pro文件最后一行INTERFACES等号后面的内容要去掉的,这点手册是有问题的。
另外可以核对一下Makefile中INCPATH和LIBS是否和天嵌手册完全一样。这2地方手册没用红笔提醒的。
做好以上3步估计就没问题了,这是我的经验,希望你好运。
回复

使用道具 举报

SiJianH 发表于 2012-8-12 14:04:17 | 显示全部楼层
yuki 发表于 2012-8-12 12:48
我使用QT2是可以编译成功的,X86环境没问题的。
不过手册上有个错误:
first.pro文件最后一行INTERFACE ...

谢谢。      
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-4-28 05:02 , Processed in 1.046875 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表