首页| 论坛| 消息

标题:大家帮我看一下这是什么原因
作者:younglee
日期:2006-04-16 22:09
内容:

程序是这样的:
#include
#include
main(int argc, char **argv)
{
printf("hello\n");
}
----------------
不包含#include可以正确编译,但是包含了之后,
编译后:

make
g++ -c -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -march=i586 -mcpu=i686 -fmessage-length=\
0 -Wall -fPIC -DQT_NO_DEBUG-I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/include -I/usr/lib/qt3/include -o test.o test.cpp
test.cpp:6: warning: ISO C++ forbids declaration of `main' with no type
test.cpp: In function `int main(int, char**)':
test.cpp:6: warning: unused parameter `int argc'
test.cpp:6: warning: unused parameter `char**argv'
g++-o qt test.o -L/usr/lib/ -L/usr/X11R6/lib/ -lXext -lX11 -lm
test.o(.gnu.linkonce.d._ZTV6QGList+0xc): undefined reference to `QGList::clear()'
test.o(.gnu.linkonce.d._ZTV6QGList+0x10): undefined reference to `QGList::~QGList ()'
test.o(.gnu.linkonce.d._ZTV6QGList+0x14): undefined reference to `QGList::~QGList ()'
test.o(.gnu.linkonce.d._ZTV6QGList+0x18): undefined reference to `QPtrCollection::newItem(void*)'
test.o(.gnu.linkonce.d._ZTV6QGList+0x20): undefined reference to `QGList::compareItems(void*, void*)'
test.o(.gnu.linkonce.d._ZTV6QGList+0x24): undefined reference to `QGList::read(QDataStream&, void*&)'
test.o(.gnu.linkonce.d._ZTV6QGList+0x28): undefined reference to `QGList::write(QDataStream&, void*) const'
test.o(.gnu.linkonce.d._ZTI6QGList+0x8): undefined reference to `typeinfo for QPtrCollection'
test.o(.gnu.linkonce.d._ZTV15QDragEnterEvent+0x10): undefined reference to `QDropEvent::format(int) const'
test.o(.gnu.linkonce.d._ZTV15QDragEnterEvent+0x14): undefined reference to `QDropEvent::encodedData(char const*) const'
test.o(.gnu.linkonce.d._ZTV15QDragEnterEvent+0x18): undefined reference to `QDropEvent::provides(char const*) const'
......
..


#1 [alexzhao 04-17 22:47]
老天,你去看看helloworld的程序再写吧
#2 [liu_ming50 07-03 15:11]
在qt程序里使用printf(x...)要如下包含头文件
extern "C"{
#include
}
试一下吧,没道理会那样。

回复 发表
主题 版块