㈠ linuxqt缂栬疟
linux涓嬫墽琛宷t绋嫔簭镐庝箞缂栬疟杩愯岋纻
1銆佸湪Linux涓嬬殑锻戒护琛岀紪杈戠▼搴忥细#mkdirhello//mkdir锻戒护鍒涘缓涓涓猦ello鐩褰#cdhello//cd锻戒护鍒囨崲鍒板垰镓嶅垱寤虹殑hello鐩褰#vimain.cpp//鍦╤ello鐩褰曚腑鐢╲i鍒涘缓涓涓猰ain.cpp鏂囦欢灏嗕笅闱㈢殑浠g爜杈揿叆鍒癿ain.cpp鏂囦欢涓#include
镐庢牱鍦╱buntu涓嫔畨瑁卶t宓屽叆寮忥纻
1cd~/Qtenv 2 3chmo+xqt-sdk-linux-x86-opensource-2010.04.bin 4 5./qt-sdk-linux-x86-opensource-2010.04.bin 涓轰简鏂囦欢绠$悊鏂逛究锛屽皢sdk涔熷畨瑁呭湪Qtenv鏂囦欢澶逛腑銆 2銆佽В铡嬫簮浠g爜鍖 鍦ㄧ敤鎴风洰褰曚笅寤虹珛涓涓猀tenv鐩褰曪纴鐢ㄤ簬瀛樻斁缂栬疟婧愭枃浠躲 mkdir$HOME/Qtenv 鍦╭tembedded鐩褰曚笅鍒涘缓arm鍜寈86鐩褰曘傚垱寤鸿繖涓や釜鐩褰曚富瑕佹槸涓轰简缂栬疟涓涓鐢ㄦ埛arm寮鍙戠増镄凲TE锛屽彟涓涓鐩褰旷敤浜庡瓨鏀剧敤浜巕vfb镄刹86涓婹TE锛岃繖镙锋紨绀哄拰寮鍙戦兘寰堟柟渚裤 1cd~/Qtenv 2mkdirarmx86 鎺ヤ笅𨱒ュ皢婧愪唬镰佸寘鍒嗗埆澶嶅埗鍒瘾rm鍜寈86涓嫔苟瑙e帇缂┿傝繖镙峰仛铏界劧娴璐逛简涓浜涚‖鐩樼┖闂达纸ps锛氩湪瀹夸富链轰笂镄勭‖鐩桦お涓嶅奸挶浜嗭级锛屼絾鑳戒负灏嗘潵鍐嶉厤缃鍜岀紪璇戣妭鐪佸緢澶氭椂闂淬 1cd~/Qtenv 2mvqt-everywhere-opensource-src-4.6.3.tar.bz2./arm 3cd~/Qtenv/arm 4tarxjvfqt-everywhere-opensource-src-4.6.3.tar.bz2 5 6cd~/Qtenv/x86 7mvqt-everywhere-opensource-src-4.6.3.tar.bz2./x86 8tarxjvf./x86/qt-everywhere-opensource-src-4.6.3.tar.bz2 瑙e帇缂╁悗鍒嗗埆阍埚笕rm骞冲彴鍜寈86骞冲彴杩涜岄厤缃锛岄厤缃鍓嶅彲杈揿叆 ./configure-embedded-help 杩涜岄厤缃甯锷╂煡璇锛屾牴鎹骞冲彴閰岖疆锛屽苟缂栬疟鍜屽畨瑁呮枃浠躲傚叾锻戒护浠g爜濡备笅锛 1cd~/Qtenv/arm 2./configure-prefix$HOME/Qtenv/arm-embeddedarm-nomakedocs-nomakedemo-nomakeexamples 3make 4makeinstall 5 6cd~/Qtenv/x86 7./configure-prefix$HOME/Qtenv/arm-embeddedx86-nomakedocs-nomakedemo-nomakeexamples 8make 9makeinstall 鍦ㄧ粡杩囨极闀跨殑閰岖疆銆佺紪璇戝悗灏卞畬鎴愪简QTE镄勫畨瑁呫傛湰浜哄湪arm鐗堢殑缂栬疟杩囩▼涓鍑虹幇杩囦袱涓阌栾锛屽湪鍙傝冦婂湪arm-linux-gcc3.4.1涓嬬紪璇憅t-embedded-4.6.2銆嫔畬鎴愮紪璇戙 瀹屾垚缂栬疟鍜屽畨瑁呭悗闇瑕佸圭郴缁熺殑鐜澧冨彉閲忚繘琛岃剧疆锛岃剧疆鍙浠ユ槸涓存椂镐ц剧疆鍜屾案涔呮ц剧疆銆备复镞惰岃剧疆鏄鐩存帴鍦ㄥ懡浠ょ獥鍙h緭鍏 1exportQTENV=$HOME/Qtenv 2exportQTXDIR=$QTENV/qtsdk 3exportQTEDIR=$QTENV/x86 4exportPATH=$QTXDIR/qt/bin:$PATH 5exportLD_LIBRARY_PATH=$QTXDIR/lib:$LD_LIBRARY_PATH 6exportQVFBDIR=$QTXDIR/qt/bin 7exportQTEMAKEDIR=$QTEDIR/bin 浠ヤ笂杩欎簺鍙橀噺鍙浠ユ牴鎹镊宸辩殑锽滃ソ杩涜屽炲垹銆傝繖绉嶈剧疆鏂规硶鍦ㄥ叧闂褰揿墠锻戒护缁堢钖庡け鏁堛 绗浜岀嶆柟寮忔槸鍦ㄥ綋鍓岖敤鎴风殑涓荤洰褰曚笅锛岀紪杈.bash_profile鏂囦欢锛屽姞鍏ヤ笂杩板懡浠よ岋纴淇濆瓨閲嶅惎锻戒护缁堢鍗冲彲銆
濡备綍鍦ˋRMLinux鐜澧冧腑鎼寤篞T杩愯岀幆澧冿纻
1銆佸彲浠2銆丵tCreator鍙鏄涓涓闆嗘垚寮鍙戝伐鍏凤纴杩欎釜鐗堟湰闅忔剰锛岀绣涓娄笅灏卞彲浠ワ纴Qte涓嶆槸鐢ㄦ渶鏂帮纴钥屾槸链濂界敤璺熶綘鍦↙inux寮鍙板紑鍙戜竴镙风殑銆傞栧厛瑕佸湪Linux涓嬩氦鍙夌紪璇恸te镄勫簱锛岀劧钖庡啀灏哃ib杩欎簺鏂囦欢绉绘嶅湪𨱒垮瓙涓婏纴链钖庨氲繃浜ゅ弶缂栬疟濂界殑搴揿幓缂栬疟浣犲湪pc
镙戣帗娲句笅镐庢牱杩愯岀Щ妞岖殑QT绋嫔簭锛
浣犲彲浠ュ弬钥侨QLiteStudio杩欎釜Qt鍐欑殑璺ㄥ钩鍙癝QLite绠$悊宸ュ叿,瀹冭嚜宸辨墦鍖呬简渚濊禆镄凲t搴,鍙浠ュ仛鍒拌В铡嫔嵆鐢,鍏煎逛笉钖孡inux鍙戣岀増.阆撶悊鍏跺疄璺焀indows鐗圦t绋嫔簭镊甯Qt搴揿樊涓嶅.
缂栬疟鍓岖粰杩炴帴鍣ㄤ紶涓涓鍙傛暟:
璇存槑:
-Wl琛ㄧず锻婅瘔缂栬疟鍣ㄥ皢钖庨溃镄勫弬鏁颁紶阃掔粰阈炬帴鍣.
rpath鏄痝cc镄勪竴涓鍙傛暟,褰撶▼搴忚锷犺浇镞,浼氭悳瀵籸path鐩褰,瀵绘垒鍏变韩搴.
rpath娣诲姞镄勭洰褰曚俊鎭淇濆瓨鍦ㄥ彲镓ц屾枃浠朵腑.
$ORIGIN琛ㄧず鍙镓ц屾枃浠舵墍鍦ㄧ殑鐩褰.
涔熷氨鏄杩愯屾椂绋嫔簭浼氩厛铡昏嚜宸辨墍鍦ㄧ殑鐩褰旷殑lib閲屽幓锷犺浇渚濊禆搴,娌℃湁镄勮瘽鍐嶅幓绯荤粺搴挞噷镓.
濡傛灉浣犵殑绋嫔簭鍦ㄧ紪璇戞椂娌℃湁浼犻抮path鍙傛暟,闾d綘涔熷彲浠ョ敤patchelf𨱒ヤ慨鏀逛綘绋嫔簭镄剅path:
娉ㄦ剰:patchelf淇鏀规枃浠跺悗鍐岘trip浼氩艰嚧鏂囦欢鎹熷潖.
镓浠ュ簲璇ュ厛鐢╯trip鍒犻櫎绗﹀彿琛ㄧ缉灏忎簩杩涘埗鏂囦欢,铹跺悗鍐岖敤patchelf璁剧疆rpath.
棰桦栬瘽,Android涓婃棦娌℃湁glibc搴,涔熸病链夊簱阈炬帴鍣╨d-linux.so.3.
濡傛灉浣犺佹妸DebianARM(濡傛爲銮撴淳Raspbian)涓婄殑杞浠舵斁鍒痨ndroid涓婅窇,浣犱竴镙峰彲浠ユ墦鍖呯▼搴忎緷璧栫殑鍏变韩搴,璁╃▼搴忎篃鑳借窇鍦ˋndroid涓,姣斿侾HP:
涔熷氨鏄浣犳妸搴挞摼鎺ュ櫒ld-linux-armhf.so.3鍜孭HP渚濊禆镄勫簱閮芥斁鍒/data/local/tmp/web/lib閲,铹跺悗璁剧疆涓鍒钖,灏辫兘鍦ˋndroid镄刟dbshell閲岃繍琛屾爲銮撴淳镄凯HP浜.
褰撶劧,浣犱篃鍙浠ョ敤patchelf璁剧疆PHP镄刬nterpreter鍜宺path,鏁堟灉宸涓嶅:
镐庢牱浜ゅ弶缂栬疟涓涓猀T搴旂敤绋嫔簭锛
1.璁剧疆鐜澧冨彉閲忥细rPATH锛濇坊锷犱负浜ゅ弶鐜澧冧笅缂栬疟钖庣敓鎴愮殑qmake璺寰勶纴阃氩父鍜屼富链虹殑绯荤粺鏄涓绉嶆灦鏋勶纴钖屾椂闇瑕佺‘淇濅氦鍙塯cc缂栬疟鍣ㄥ湪鍦≒ATH瀹氢箟rQMAKESOEC锛濅氦鍙夌紪璇戠殑瀵硅薄镄勭殑骞冲彴鎻忚堪鏂囦欢锛屼緥濡俶akespec/qws/linux-arm-g++rQTDIR=Qt镄勫畨瑁呮枃浠讹纴瀛樻斁杩椤簱鍜屽ご鏂囦欢rLD_LIBRARY_PATH=瀛樻斁镄勬槸Qt镄勪氦鍙夌紪璇戝悗镄勫簱锛屽嗳澶囦负鐩镙囩紪璇戦摼鎺ョ殑搴搑2銆傛墽琛岀幆澧冨彉閲弐阃氩父鎴戜滑閮戒细灏嗕互涓婄殑璁剧疆鏀剧疆鍦ㄤ竴涓狰ash鑴氭湰涓锛岄渶瑕佺殑镞跺椤氨镓ц屼竴涓嬨傚紑濮嬬紪璇憆1.浣跨敤qmake锛峱roject𨱒ョ敓鎴愰”鐩鏂囦欢****.pror2浣跨敤qmake𨱒ョ敓鎴怣akefile鏂囦欢r3浣跨敤make𨱒ョ紪璇戠Щ妞嶏细浣跨敤readeif宸ュ叿𨱒ュ垎鏋愮洰镙囩郴缁熺殑浠ユ潵搴掳纴铹跺悗鐩稿叧镄勫簱鍒扮洰镙囨枃浠剁郴缁熷唴銆傞氩父鎴戜滑涔熸槸閲囧彇鑴氭湰镄勬柟寮忔潵瀹屾垚銆俽涓鑸钥岃█锛屽嚒鏄链夎勫緥镄勬垨钥呴吨澶嶆х殑宸ヤ綔锛屾垜浠閮藉彲浠ラ噰鍙栬剼链镄勬柟寮忔潵瑙e喅銆
㈡ linux绋嫔簭缂栬疟linux绋嫔簭缂栬疟
鍦╨inux閲岋纴c绋嫔簭镄勭紪杈戙佺紪璇戙佽皟璇旷殑璇︾粏姝ラゆ槸浠涔堬纻
鍦╨inux涓嬶纴涓鑸镄刢绋嫔簭寮鍙戞祦绋嬩负锛歝绋嫔簭镄勭紪杈戯细涓鑸𨱍呭喌涓嬶纴绠鍗旷殑c绋嫔簭缂栬緫鏄阃氲繃vi鏂囨湰缂栬緫鍣ㄨ繘琛岀殑锛岃娉曟牸寮忓拰鍦╳indows涓嬬殑缂栬緫鏄涓镙风殑锛
c绋嫔簭镄勭紪璇戯细钥岀紪璇戝垯鏄瀵圭紪杈戝ソ镄刢璇瑷绋嫔簭杩涜屼竴涓锛岄勫勭悊锛岀紪杈戯纴姹囩紪鍜岄摼鎺ョ殑杩囩▼锛屼竴鑸镙煎纺涓:缂栬疟鍣ㄥ悕-鍙傛暟鐩镙囨枃浠跺悕婧愭枃浠跺悕锛涗竴鑸宸ヤ綔鍦ㄥ懡浠よ屾ā寮忥绂
c绋嫔簭镄勮皟璇曪细璋冭瘯阒舵靛垯鏄寤虹珛鍦╟绋嫔簭缂栬疟阃氲繃镄勬儏鍐典笅杩涜岀殑锛屼竴鑸阃氲繃GDB璋冭瘯杩涜岋纴阃愭ユ帓阌椤拰缁呜妭镆ョ湅銆
鍦╨inux涓锛屾庝箞鐢╣cc缂栬疟鏂囦欢锛
缂栬疟鏂规硶锛氭牸寮廹cc甯哥敤镄勯夐”链绠鍗旷殑鏄:gcchello.c榛樿ょ殑𨱍呭喌涓嫔皢鐢熸垚a.out镄勫彲镓ц屾ф枃浠讹纴鍙闇瑕佸湪缁堢涓婅緭鍏./a.out灏卞彲浠ョ湅鍒版墽琛岀殑缁撴灉锛屽傛灉浣犳兂鎸囧畾鐢熸垚鐩镙囨枃浠剁殑钖嶅瓧闾d箞浣犲彲浠ュ姞涓-o阃夐”,锻戒护濡备笅:gcc-ohellohello.c锻戒护锛欢cc-chellohello.c
镓╁𪾢璧勬枡锛
gcc锻戒护镄勫熀链鐢ㄦ硶gcc鍏朵腑锛宖ilenames涓烘枃浠跺悕锛沷ptions涓虹紪璇戦夐”銆傚綋涓崭娇鐢ㄤ换浣旷紪璇戦夐”缂栬疟hello.c镞讹纴gcc灏嗕细镊锷ㄧ紪璇戜骇鐢熶竴涓猘.out镄勫彲镓ц屾枃浠讹细#lshello.c#gcchello.c#lsa.outhello.c镓ц岋细#./a.outHello,World!浣跨敤-o缂栬疟阃夋嫨锛屽彲浠ヤ负缂栬疟钖庣殑鏂囦欢鎸囧畾涓涓钖嶅瓧锛#lsa.outhello.c#gcchello.c-ohello#lsa.outhellohello.c镓ц岋细#./helloHello,World!娉ㄦ剰锛氢娇鐢-o阃夐”镞讹纴-o钖庨溃蹇呴’璺熶竴涓鏂囦欢钖嶏纴鍗筹细-ooutfile銆备负浜嗕究浜庢弿杩板悗闱㈢殑阃夐”锛屽垹闄hello鍜宎.out鍙镓ц屾枃浠躲linux鍏ラ棬锘虹锛堜笁锛塆cc缂栬疟缂栫▼锛
銆愬笇链涘逛綘链夊府锷┿
寤鸿浣犵湅鐪嬬紪绋嬬殑涓浜涘熀纭鐭ヨ瘑
-缁忓吀helloword绋嫔簭
#includestdio.h>
intmian()
{
printf("helloworld!n");
return0;
}
-缂栬疟
-杩涘叆缁堢
-杩涘叆婧愭枃浠舵墍鍦ㄧ殑鐩褰
$gcchello.c-ohello
-杩愯
$./hello
arm-linux-gcc镐庝箞缂栬疟鏂囦欢锛
鍙浠ヤ娇鐢╣cc锻戒护杩涜岀紪璇戯细渚嫔瓙锛欢cc-ohellohello.c#鍦ㄨ繖閲宧ello.c鏄婧愭枃浠讹纴hell涓虹洰镙囱緭鍑烘枃浠堕氲繃缂栬疟鍣ㄧ紪璇戜富瑕佹槸缁忚繃锛氶勫勭悊锛屾眹缂栵纴缂栬疟鍜岄摼鎺ョ殑杩囩▼锛
linux濡备綍缂栬疟杩愯宼est.c锛
鎴戠殑锛欢cc-ctest.c-oa.out缂栬疟
./a.out杩愯