{"id":161,"date":"2013-12-27T15:00:05","date_gmt":"2013-12-27T07:00:05","guid":{"rendered":"http:\/\/www.datarelab.com\/blog\/?p=161"},"modified":"2013-12-27T15:00:05","modified_gmt":"2013-12-27T07:00:05","slug":"linux%20%e4%b8%8b%e7%bc%96%e8%af%91%e5%b9%b6%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%20qt%20%e5%85%a8%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.datarelab.com\/blog\/Technical_literature\/161.html","title":{"rendered":"Linux \u4e0b\u7f16\u8bd1\u5e76\u5b89\u88c5\u914d\u7f6e Qt \u5168\u8fc7\u7a0b"},"content":{"rendered":"<p>\n\t1\u3002\u83b7\u5f97\u6e90\u4ee3\u7801\n<\/p>\n<p>\n\tsrc \u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff1aftp:\/\/ftp.qt.nokia.com\/qt\/source\/\n<\/p>\n<p>\n\t2009 \u5e74 10 \u6708 1 \u65e5\u53d1\u5e03\u7684 qt-x11-opensource-src-4.5.3.tar.gz\uff0c\u5927\u5c0f 122 Mb\u3002\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">2\u3002\u89e3\u538b\u7f29<\/span>\n<\/p>\n<p>\n\t&nbsp;tar xvfz qt-x11-opensource-src-4.5.3.tar.gz\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">3\u3002\u751f\u6210 makefile \u6587\u4ef6<\/span>\n<\/p>\n<p>\n\t.\/configure\n<\/p>\n<p>\n\t\u8fd9\u4e2a\u65f6\u5019\u4ed6\u4f1a\u95ee\u4f60\uff1a\u201cWhich edition of Qt do you want to use?\u201d\n<\/p>\n<p>\n\t\u7136\u540e\u7ed9\u4f60\u4e24\u4e2a\u7c7b\u578b\u4f9b\u9009\u62e9\uff1a\n<\/p>\n<p>\n\tType 'c' if you want to use the Commercial Edition.\n<\/p>\n<p>\n\tType 'o' if you want to use the Open Source Edition.\n<\/p>\n<p>\n\t\u7b2c\u4e00\u4e2a\u662f\u5546\u4e1a\u7248\uff0c\u7b2c\u4e8c\u4e2a\u662f\u81ea\u7531\u7248\u3002\n<\/p>\n<p>\n\t\u9009\u62e9 'o'\uff08Qt\/\u5d4c\u5165\u5f0f\u81ea\u7531\u7248\u662fQt\u4e3a\u4e86\u5f00\u53d1\u81ea\u7531\u8f6f\u4ef6\u63d0\u4f9b\u7684\u5d4c\u5165\u5f0f\u7248\u672c\uff09\u3002\n<\/p>\n<p>\n\t\u8fd9\u65f6\u5019\uff0c\u51fa\u73b0\u8bb8\u53ef\u754c\u9762\u3002\n<\/p>\n<p>\n\t\u9009\u62e9 &nbsp;'yes' \u63a5\u53d7\u8bb8\u53ef\u534f\u8bae\u3002\n<\/p>\n<p>\n\t\u5f00\u59cb\u751f\u6210 makefile \u6587\u4ef6\u3002\u8fd9\u4e2a\u5927\u7ea6\u9700\u8981 5 -10 \u5206\u949f\u7684\u65f6\u95f4\u3002\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">4\u3002Qt \u7f16\u8bd1<\/span>\n<\/p>\n<p>\n\tgmake\n<\/p>\n<p>\n\t\u8fd9\u4e2a\u8fc7\u7a0b\u65f6\u95f4\u6bd4\u8f83\u957f\uff0c\u9700\u8981\u4e24\u4e2a\u5c0f\u65f6\u5de6\u53f3\u3002\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">5\u3002Qt \u5b89\u88c5<\/span>\n<\/p>\n<p>\n\t\u8fd0\u884c gmake install\n<\/p>\n<p>\n\t\u9ed8\u8ba4\u5b89\u88c5\u81f3 \/usr\/local\/Trolltech\/Qt-4.5.3\n<\/p>\n<p>\n\t\u5927\u7ea6 5 \uff0d 10 \u5206\u949f\u3002\u6b63\u5e38\u7ed3\u675f\uff0c\u5b89\u88c5\u5b8c\u6bd5\u3002\n<\/p>\n<p>\n\t\u8fd0\u884c \/usr\/local\/Trolltech\/Qt-4.5.3\/bin\/designer \uff0c\u770b\u89c1 qt \u542f\u52a8\uff0c\u4e5f\u5c31\u662f\u8bf4 qt \u5b89\u88c5\u597d\u4e86\u3002\n<\/p>\n<p>\n\t6\u3002\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">\u4e00\u3002\u5148\u4fee\u6539\u7528\u6237\u73af\u5883\u53d8\u91cf<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">vi \/home\/defonds\/.bashrc<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">\u5728\u5176\u6700\u540e\u6dfb\u52a0\u4ee5\u4e0b\u4fe1\u606f<\/span>\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp;export QTDIR=\/usr\/local\/Trolltech\/Qt-4.5.3\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; export PATH=$QTDIR\/bin:$PATH\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; export MANPATH=$QTDIR\/man:$MANPATH\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; export LD_LIBRARY_PATH=$QTDIR\/lib:$LD_LIBRARY_PATH\n<\/p>\n<p>\n\t\u4e8c\u3002\u518d\u4fee\u6539\u6240\u6709\u7528\u6237\u73af\u5883\u53d8\u91cf\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp;vi \/etc\/profile\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u5728\u5176\u6700\u540e\u6dfb\u52a0\u4ee5\u4e0b\u4fe1\u606f\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp;export QTDIR=\/usr\/local\/Trolltech\/Qt-4.5.3\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; export PATH=$QTDIR\/bin:$PATH\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; export MANPATH=$QTDIR\/man:$MANPATH\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp; export LD_LIBRARY_PATH=$QTDIR\/lib:$LD_LIBRARY_PATH\n<\/p>\n<p>\n\t&nbsp; &nbsp; &nbsp; &nbsp;\u4e09\u3002\u6d4b\u8bd5\u4e00\u4e0b\n<\/p>\n<p>\n\t\u91cd\u65b0\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u8f93\u5165\u547d\u4ee4\uff1a\n<\/p>\n<p>\n\tqmake -v\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">QMake version 2.01a<\/span>\n<\/p>\n<p>\n\tUsing Qt version 4.5.3 in \/usr\/local\/Trolltech\/Qt-4.5.3\/lib\n<\/p>\n<p>\n\t\u8f93\u5165\u547d\u4ee4\uff1a\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">which qmake<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">\/usr\/local\/Trolltech\/Qt-4.5.3\/bin\/qmake<\/span>\n<\/p>\n<p>\n\t\u8bc1\u660e Qt \u73af\u5883\u53d8\u91cf\u5df2\u7ecf\u88ab\u914d\u7f6e\u6210\u529f\u3002\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">&nbsp;\u7f16\u8005\u6309 \uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">Linux \u542f\u52a8\u65f6\uff0c\u5148\u8bfb\u53d6\u7528\u6237\u73af\u5883\u53d8\u91cf\uff0c\u5373 \/home\/defonds\/.bashrc \u7684\u8bbe\u7f6e\u3002\u6b21\u8bfb\u53d6\u6240\u6709\u7528\u6237\u73af\u5883\u53d8\u91cf\uff0c\u5373 \/etc\/profile \u4e2d\u7684\u914d\u7f6e\u3002<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">\u5f00\u59cb Qt<\/span>\n<\/p>\n<p>\n\t<span style=\"line-height:1.5;\">\u5199\u4e2a\u7b80\u5355\u7684 Qt \u7a0b\u5e8f\u4f7f\u7528\u5b89\u88c5\u7684 Qt \u7f16\u8bd1\u6765\u6d4b\u8bd5\u4e00\u4e0b\u5b83\u7684\u5de5\u4f5c\u6548\u679c<\/span>\n<\/p>\n<p>\n\t\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u540d\u4e3a hello.cpp\uff0c\u5176\u5185\u5bb9\u5982\u4e0b\uff1a\n<\/p>\n<p>\n\t\n<\/p>\n<pre class=\"brush:cpp; toolbar: true; auto-links: true;\">#include &lt;QApplication&gt;\r\n#include &lt;QLabel&gt;\r\nint main(int argc,char *argv[])\r\n{\r\n\tQApplication app(argc,argv);\r\n\tQLabel *label = new QLabel(\"Hello Qt!\");\r\n\tlabel-&gt;show();\r\n\treturn app.exec();\r\n}<\/pre>\n<p>\n\t\u4fdd\u5b58 hello.cpp\uff0c\u7f16\u8bd1\u8fc7\u7a0b\u5982\u4e0b\uff1a\n<\/p>\n<p>\n\t\u5728 hello.cpp \u6240\u5728\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u547d\u4ee4\n<\/p>\n<p>\n\tqmake -project\n<\/p>\n<p>\n\thello.cpp \u540c\u76ee\u5f55\u4e0b\u6709 hello.pro \u6587\u4ef6\u88ab\u751f\u6210\uff0c\u5b83\u662f\u4e0e\u5e73\u53f0\u65e0\u5173\u7684\u5de5\u7a0b\u6587\u4ef6\u3002\n<\/p>\n<p>\n\t\u5728 hello.cpp \u6240\u5728\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u547d\u4ee4\n<\/p>\n<p>\n\tqmake hello.pro\n<\/p>\n<p>\n\t\u540c\u76ee\u5f55\u4e0b\u6709 Makefile \u6587\u4ef6\u88ab\u751f\u6210\uff08Makefile\u662f\u6307\u5bfc\u7f16\u8bd1\u5668\u7f16\u8bd1\u6e90\u4ee3\u7801\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5728\u5176\u76ee\u5f55\u4e0b\u8f93\u5165make\u547d\u4ee4(nmake\u5728win32,vc6\u73af\u5883)\u5c31\u53ef\u4ee5\u5b8c\u6210\u7f16\u8bd1\uff09\u3002\n<\/p>\n<p>\n\t\u5728 hello.cpp \u6240\u5728\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u547d\u4ee4\n<\/p>\n<p>\n\tmake\n<\/p>\n<p>\n\t\u540c\u76ee\u5f55\u4e0b\u6709 hello,hello.o \u4e24\u4e2a\u6587\u4ef6\u88ab\u7f16\u8bd1\u751f\u6210\u3002\u5176\u4e2d hello \u5c31\u662f\u5728\u5f53\u524d Linux \u7cfb\u7edf\u4e0b\u4f7f\u7528 Qt \u7f16\u8bd1\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e86\u3002\u53cc\u51fb\u8fd0\u884c hello\uff0c\u201cHello Qt!\u201c \u6587\u672c\u6846\u5f39\u51fa\uff0cOK\uff01\u505a\u5230\u8fd9\u4e00\u6b65\uff0c\u8bc1\u660e Qt \u5df2\u7ecf\u5b8c\u5168\u53ef\u4ee5\u5728\u4f60\u7684\u7535\u8111\u4e0a\u8fd0\u4f5c\u4e86\u3002\u8fd8\u7b49\u4ec0\u4e48\u5462\uff0c\u5f00\u59cb\u4f60\u7cbe\u5f69\u800c\u53c8\u6109\u5feb\u7684 Qt \u5f00\u53d1\u4e4b\u65c5\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3002\u83b7\u5f97\u6e90\u4ee3\u7801 src \u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff1aftp:\/\/ftp.qt.nokia.com\/qt\/source\/ 20 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14,152],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-Technical_literature","tag-linux","tag-qt"],"views":1381,"_links":{"self":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/comments?post=161"}],"version-history":[{"count":0,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/161\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/media?parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/categories?post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/tags?post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}