qt4ÖÐÈçºÎµ÷ÓÃCº¯Êý£¨linuxÏ£©
qtĬÈϵıà³ÌÓïÑÔΪC++ÓïÑÔ¡£Èç¹ûÄãÓÃqt±àÒë.cÎļþ£¬»á³öÏÖÕÒ²»µ½CÓïÑÔµÄĬÈÏÍ·ÎļþµÈ´íÎó£¨È磺stdio.hµÈ£©¡£qtÖв»Ö§³Ö
extern "C"{}µÄÕâÖÖд·¨£¬ÎÒÇ°¼¸ÌìÓÐÒ»¸öC³ÌÐòÐèÒªÒÆÖ²µ½QtµÄ¹¤³ÌÖУ¬±¾Ï£ÍûÖ±½Óextern "C"¾ÍokÁË£¬µ«·¢ÏÖqt4¾ÓÈ»²»Ö§³ÖÕâÖÖд·¨¡£ÎҵijÌÐòÖÐÓõ½Á˺ü¸¸ölinuxϵͳͷÎļþ£¬ÊÇÏò´®¿Ú·¢Ö¸ÁîÖ®ÀàµÄ³ÌÐò£¬³ÌÐòÖÐÓõ½ÁË»¥³âËø²¢´´½¨ÁËÒ»¸öÏ̡߳£Èç¹ûÔÙÓÃqtÓïÑÔÀ´Ð´Ò»±éµÄ»°ÎÒ»á¹ÒµôµÄ£¬ËùÒÔûÓа취£¬ÔÚÍøÉÏÕÒÁË°ëÌ죬ÖÕÓÚÕÒµ½½â¾ö·½·¨¡£
½«.cÎļþ±àÒëΪº¯Êý¿âµÄ·½Ê½ÔÚqtϵ÷Óã¬ÕâÖÖ·½·¨Ã²ËÆÐеÃͨ£¬ÎҾͿªÊ¼Ðж¯ÁË¡£
ÏÂÃæµÄÄÚÈݽ²µÃ±È½Ï¶à£¬±È½ÏÈ«£¬±È½ÏÊʺϳõѧÕߣ¬ÊÇÎÒÔÚÍøÉÏdownµÄ£¬¸ø³öÁËÔÍøÕ¾µÄÁ´½Ó£¬×îºó¸ø³öÁËÒ»¸ö³ÌÐò¡£¾¹ý×Ô¼ºÕûÀíºÃ¹éÄÉÈçÏ£º
ÐèҪ˵Ã÷µÄÊÇ£ºÊ¹ÓÃgcc¿ÉÒÔ½«³ÌÐò±àÒë³É¶¯Ì¬¿â»òÕß¾²Ì¬¿âµÄÐÎʽ£¬ËüÃÇÔÚ³ÌÐòÖеĵ÷Óõķ½Ê½Ò²²»¾¡Ïàͬ£¬¸ø³öµÄ³ÌÐòÖе÷ÓõÄÊǶ¯Ì¬Á¬½Ó¿â¡£±àÒë³É¶¯Ì¬µÄ»¹ÊǾ²Ì¬µÄ¸ù¾Ý×Ô¼ºµÄÐèÒª½øÐС£Èç¹ûÔC³ÌÐò±àÒëµÄʱºòÐèÒªgccµÄ¶îÍâÑ¡Ïî(Èç gcc -lpthread -o hello hello.c)µÈ£¬½¨Òé²ÉÓö¯Ì¬µÄÐÎʽ¡£
1.ʲôÊǾ²Ì¬Á¬½Ó¿â£¬Ê²Ã´ÊǶ¯Ì¬Á´½Ó¿â
¾²Ì¬Á´½Ó¿âÓ붯̬Á´½Ó¿â¶¼Êǹ²Ïí´úÂëµÄ·½Ê½£¬Èç¹û²ÉÓþ²Ì¬Á´½Ó¿â£¬ÔòÎÞÂÛÄãÔ¸²»Ô¸Ò⣬lib ÖеÄÖ¸Áȫ²¿±»Ö±½Ó°üº¬ÔÚ×îÖÕÉú³ÉµÄ EXE ÎļþÖÐÁË¡£µ«ÊÇÈôʹÓà DLL£¬¸Ã DLL ²»±Ø±»°üº¬ÔÚ×îÖÕ EXE ÎļþÖУ¬EXE ÎļþÖ´ÐÐʱ¿ÉÒÔ“¶¯Ì¬”µØÒýÓúÍжÔØÕâ¸öÓë EXE ¶ÀÁ¢µÄ DLL Îļþ¡£¾²Ì¬Á´½Ó¿âºÍ¶¯Ì¬Á´½Ó¿âµÄÁíÍâÒ»¸öÇø±ðÔÚÓÚ¾²Ì¬Á´½Ó¿âÖв»ÄÜÔÙ°üº¬ÆäËûµÄ¶¯Ì¬Á´½Ó¿â»òÕß¾²Ì¬¿â£¬¶øÔÚ¶¯Ì¬Á´½Ó¿âÖл¹¿ÉÒÔÔÙ°üº¬ÆäËûµÄ¶¯Ì¬»ò¾²Ì¬Á´½Ó¿â¡£ÔÚwindowsºÍlinuxÉ϶¼ÊÇÏàͬµÄ£¬Ö»²»¹ýÎļþµÄ¸ñʽ²»Í¬¶øÒÑ¡£
http://www.cnblogs.com/winston/archive/2008/07/05/1236273.html
2.gccÉú³É¾²Ì¬¿âºÍ¶¯Ì¬¿â
µÚ1²½£º±à¼µÃµ½¾ÙÀýµÄ³ÌÐò--hello.h¡¢hello.cºÍmain.c£»
µÚ2²½£º½«hello.c±àÒë³É.oÎļþ£»
ÎÞÂÛ¾²Ì¬¿â£¬»¹ÊǶ¯Ì¬¿â£¬¶¼ÊÇÓÉ.oÎļþ´´½¨µÄ¡£Òò´Ë£¬ÎÒÃDZØÐ뽫Դ³ÌÐòhello.cͨ¹ýgccÏȱàÒë³É.oÎļþ¡£
ÔÚϵͳÌáʾ·ûϼüÈëÒÔÏÂÃüÁîµÃµ½hello.oÎļþ¡£
# gcc -c hello.c
µÚ3²½£ºÓÉ.oÎļþ´´½¨¾²Ì¬¿â£»
¾²Ì¬¿âÎļþÃûµÄÃüÃû¹æ·¶ÊÇÒÔlibΪǰ׺£¬½ô½Óןú¾²Ì¬¿âÃû£¬À©Õ¹ÃûΪ.a¡£ÀýÈ磺ÎÒÃǽ«´´½¨µÄ¾²Ì¬¿âÃûΪmy
Ïà¹ØÎĵµ£º
1.×Ö·ûÉ豸Óë¿éÉ豸IO²Ù×öµÄÇø±ð
1)¿éÉ豸ֻÄÜÒÔ¿éΪµ¥Î»½ÓÊÕÊäÈë·µ»ØÊä³ö,¶ø×Ö·ûÉ豸ÔòÒÔbyteΪµ¥Î».´ó¶àÊýÉ豸ÊÇ×Ö·ûÉ豸,ËûÃDz»ÐèÒª»º³å²¢ÇÒ²»ÒԹ̶¨¿é´óС½øÐвÙ×÷.
2)¿éÉ豸¶ÔÓÚIOÇëÇóÓжÔÓ¦µÄ»º³åÇø,ËùÒÔËûÃÇ¿ÉÒÔÑ¡ÔñÒÔʲô˳Ðò½øÐÐÏìÓ¦.×Ö·ûÉ豸ÎÞÐ뻺³åÇÒ±»Ö±½Ó¶Áд.
3)×Ö·ûÉ豸ֻÄܱ»Ë³Ðò¶Áд, ......
ÍøÂçÉϺÍÊéÉÏÓи÷ÖÖÅäÖÃJDK»·¾³±äÁ¿µÄ·½·¨£¬µ«ÊÇÈ·ÃèÊö²»Ò»Ö£¬¸ø³õѧÕßÔì³ÉÁËÒ»¶¨µÄÀ§ÄÑ£¨ÏëÆðµ±Ê±µÄÎÒ£©¡£ÒÔÏÂÊÇÎÒ×Ô¼º×ܽáµÄ£¬°Ù·Ö°Ù¿ÉÒÔÓá£
´ËÎÄÏêÊöÁËÈçºÎÔÚwindowsºÍlinuxÏÂÅäÖû·¾³±äÁ¿¡£
Ò»¹²ÐèÒªÅäÖÃ3¸ö±äÁ¿£º
JAVA_HOME£ºÖ÷ÒªÊÇΪÁËÆäËüÁ½¸öʹÓ㬼ò»¯ÅäÖã¬jdk°²×°µÄÍêÕûµÄ·¾¶Ãû£¬Ò»Ö±µ½jdk...Ϊֹ¡£
CLAS ......
1. ÓÐЩÃüÁî²ÎÊý¹ý¶à£¬¿ÉÒÔÓÃgrepÀ´·½±ã²éÕÒ£¬È磺
iptables -h 2>&1|grep '\-A'
ÆäÖÐ2>&1½«stderrתÏòstdout£¬È»ºóÎÒÃǾͿÉÒÔͨ¹ýgrepÕÒµ½ÐèÒªµÄÑ¡ÏҪעÒâµÄÊǺá¸Ë֮ǰҪ¼Ó·´Ð±¸ ......
3.2 ¸ßЧÂʲâÊÔ£ºËÄÁ½°Îǧ½ï
ÉÏÒ»½Ú½éÉÜÁËһЩËÆÊǶø·ÇµÄ¸ßЧÂÊ·½·¨£¬ÄÇô£¬ÔõÑù²ÅÄÜÕæÕý¸ßЧÂʲâÊÔÄØ£¿ÕæÕýµÄ¸ßЧÂÊ£¬²»ÄܺöÂÔÈ˵ÄÖÇ»ÛÕâÒ»¹Ø¼üÒòËØ¡£
ÓÉÓÚ¹¤¾ß²»¿ÉÄÜ×Ô¶¯Á˽â´úÂëµÄÉè¼Æ¹¦ÄÜ£¬Ö»ÓÐÈ˲ÅÁ˽⣬Òò´Ë£¬Ö»ÓÐÈ˵ÄÖǻۼ°Ê±½éÈ룬¹¤¾ß²ÅÄÜ×öÕýÈ·µÄÊÂÇ飬²ÅÄÜ´ïµ½ÕæÕýµÄ¸ßЧÂÊ¡£
&nb ......
ÎÊÌâÃèÊö£ºÐ´Ò»¸öº¯Êý£¬½ÓÊÜÒ»¸öÕûÊý£¨¼Ù¶¨ÓÃint±íʾ£©£¬Êä³ö¸ÃÕûÊýµÄ×Ö·û´®ÐÎʽ¡£²ÉÓÃÈçϺ¯ÊýÔÐÍ£º
void itoa ( int val, char* buf );
ÕâÀï¼Ù¶¨buf×ã¹»´óÒÔÈÝÄÉÈκÎintÀàÐÍÊýÖµµÄ×Ö·û´®¡£
Õâ¸öÎÊÌ⣬³õ¿´ºÃÏñûÓÐʲôÄѶȡ£Èç¹ûÊÇ0£¬¾ÍÖ±½ÓÊä³ö'0'£»Èç¹ûÊÇÕýÊý£¬¾Íͨ¹ýÈ¡Ä£(%)ºÍÇóÉÌ(/)ÔËËã¿ÉÒÔÖðλȡµÃ¸ÃÕûÊýµÄÊ ......