标签:io ar strong sp on 代码 ad ef linux
最近在学习《Beginning Linux Programming》4th Edition的时候,将下面的例子代码键入
#include<qapplication.h> #include<qmainwindow.h> int main(int argc,char* args[]) { QApplication app(argc,args); QMainWindow *window=new QMainWindow(); app.setMainWidget(window); window->show(); return app.exec(); }
按照 $g++ -o QWindow QWindow.cpp -I$QTDIR/include -L$QTDIR/lib -lqui 编译方式出现了如下的错误:
/usr/bin/ld: /tmp/ccizdZj7.o: undefined reference to symbol ‘_ZN7QWidget14setFocusPolicyENS_11FocusPolicyE‘ /usr/bin/ld: note: ‘_ZN7QWidget14setFocusPolicyENS_11FocusPolicyE‘ is defined in DSO /usr/lib64/qt-3.3/lib/libqt-mt.so.3 so try adding it to the linker command line /usr/lib64/qt-3.3/lib/libqt-mt.so.3: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
根据提示,直接将 /usr/lib64/qt-3.3/lib/libqt-mt.so.3作为输入,则可以正常编译成功。
$ g++ -o QWindow QWindow.cpp -I$QTDIR/include -L$QTDIR/lib -lqui $QTDIR/lib/libqt-mt.so.3
PS:在阅读本书的过程中,在中文版第四版的p427:
$./thread3a的输出部分:
FAST输入后,应该输出的是两句“You input 7 characters”
You input 7 characters
You input 7 characters
而不是书中的三句:
You input 7 characters
You input 7 characters
You input 7 characters
正在学习linux相关的知识,希望大家一起交流,共同进步。。。。
QT开发--《Beginning Linux Programming》4th Edition
标签:io ar strong sp on 代码 ad ef linux
原文地址:http://my.oschina.net/zhangwenwen/blog/335212