LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: basten54188

gcc问题!

[复制链接]
发表于 2003-5-17 17:50:57 | 显示全部楼层
/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o(.text+0x18): undefined reference to `main'

你的文件中有没有main
如果没有那么应该使用 -c
 楼主| 发表于 2003-5-17 17:53:28 | 显示全部楼层
无双兄你是什么意思???
具体说说好不?
你有QQ不?
 楼主| 发表于 2003-5-17 17:55:32 | 显示全部楼层
不会把!我用了gcc -I/$QTDIR /include -L/$QTDIR/LIB -lqt
发表于 2003-5-17 18:12:58 | 显示全部楼层
如果文件中没有main
那么应该是
gcc -I/$QTDIR /include -L/$QTDIR/LIB -lqt -c

-c 只编译不连接
 楼主| 发表于 2003-5-17 19:29:49 | 显示全部楼层
#include "form1.h"

#include <qvariant.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>


        Form1::Form1( QWidget* parent,  const char* name, WFlags fl )
   
: QWidget( parent, name, fl )
{
            if ( !name )
                setName( "Form1" );
            resize( 600, 480 );
            setCaption( trUtf8( "Form1" ) );

            PushButton1 = new QPushButton( this, "ushButton1" );
            PushButton1->setGeometry( QRect( 70, 80, 91, 60 ) );
            PushButton1->setText( trUtf8( "ushButton1" ) );

            connect( PushButton1, SIGNAL( clicked() ), PushButton1, SLOT( setFocus() ) );
}

Form1::~Form1()
{
}

这是代码!斑竹看看有问题么?
发表于 2003-5-17 20:11:31 | 显示全部楼层
QWidget( parent, name, fl )??
使用它那么就要连QT的库

另外没有使用-c表示生成可执行文件
可执行文件一定要有man


还有就是你可以创建一个QT工程然后再看看它的makefile
这最简单
 楼主| 发表于 2003-5-17 20:36:49 | 显示全部楼层
如果加-lqt会出现
gcc: -lqt: linker input file unused because linking not done
如果不加-lqt会生成FORM1.O 文件
然后就不知道怎么做了!

怎么创建QT工程啊??小弟没做过!
发表于 2003-5-18 00:30:17 | 显示全部楼层
我不懂 C++,但我至少知道用 gcc 链接 C++ 程序是会出错的。而且这里没有 main(),自然只能编译不能链接。
发表于 2003-5-18 03:05:06 | 显示全部楼层
应该用g++。
我刚学qt/kde,写了一个helloworld程序,书上给的makefile是:
INCL=-I$(QTDIR)/include -I$(KDEDIR)/include
CFLAGS=-pipe -O2 -fno-strength-reduce
LFLAGS=-L$(QTDIR)/lib -L$(KDEDIR)/lib -L/usr/X11R6/lib
LIBS=-lqt -lX11 -lXext
CC=g++

helloworld: helloworld.o
\t$(CC) $(LFLAGS) -o helloworld helloworld.o $(LIBS)

helloworld.o: helloworld.cc

clean:
\trm -f helloworld
\trm -f helloworld.o

.SUFFIXES: .cc

.cc.o:
\t$(CC) -c $(CFLAGS) $(INCL) -o $@ $<
因为本论坛缩进有问题,我用\t代表tab,使用时请替换一下,你可以改一下试试。
发表于 2003-5-18 03:07:33 | 显示全部楼层
我对一般的QT程序用上面的makefile都可以的,把后面的目标稍微改一下就行了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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