ÔÚLinuxϵͳÉÏʹÓÃCLion¾ÙÐÐǶÈëʽC/C++¿ª·¢µÄÉèÖü¼ÇÉ
ÔÚlinuxϵͳÉÏʹÓÃclion¾ÙÐÐǶÈëʽc/c++¿ª·¢µÄÉèÖü¼ÇÉ
Ëæ×ÅǶÈëʽϵͳµÄÒ»Ö±Éú³¤£¬C/C++ÈÔÈ»ÊÇ¿ª·¢Ç¶ÈëʽӦÓóÌÐòµÄÖ÷ÒªÓïÑÔ¡£¶øÔÚ¿ª·¢Àú³ÌÖУ¬ºÏÊʵļ¯³É¿ª·¢ÇéÐΣ¨IDE£©¹ØÓÚÌá¸ß¿ª·¢Ð§ÂÊÖÁ¹ØÖ÷Òª¡£CLionÊÇÒ»¿îÓÉJetBrains¿ª·¢µÄ¿çƽ̨µÄC/C++¿ª·¢ÇéÐΣ¬ËüÌṩÁËÇ¿Ê¢µÄ¹¦Ð§ºÍÓѺõÄÓû§½çÃ棬ʹµÃǶÈëʽ¿ª·¢±äµÃÔ½·¢ÇáËɺ͸ßЧ¡£
±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxϵͳÉÏÉèÖÃCLion¾ÙÐÐǶÈëʽC/C++¿ª·¢£¬²¢ÌṩһЩÊÊÓõļ¼ÇɺʹúÂëʾÀý¡£
×°ÖÃCLion
Ê×ÏÈ£¬ÎÒÃÇÐèÒª´ÓJetBrains¹ÙÍøÏÂÔØCLionµÄ×°Öðü¡£Æ¾Ö¤ÄãµÄLinux¿¯Ðа棬ѡÔñ¶ÔÓ¦µÄ×°Öðü¾ÙÐÐÏÂÔØ¡£×°ÖÃÍê³Éºó£¬·¿ªCLion²¢½øÈë³õʼÉèÖá£
ÉèÖñàÒëÆ÷ºÍ¹¹½¨ÏµÍ³
ÔÚ³õʼÉèÖýçÃæÖУ¬Ñ¡Ôñ”Toolchains”Ñ¡Ï²¢µã»÷”+”ͼ±êÌí¼ÓÒ»¸öеıàÒëÆ÷¡£Æ¾Ö¤ÄãµÄÐèҪѡÔñGCC»òÕßClang×÷Ϊ±àÒëÆ÷¡£È»ºó£¬µã»÷”OK”ÉúÑÄÉèÖá£
Á¬Ã¦Ñ§Ï°¡°C++Ãâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
½ÓÏÂÀ´£¬Ñ¡Ôñ”Build, Execution, Deployment”Ñ¡Ïµã»÷”Toolchains”ҳǩ£¬ÔÚÓÒ²àÑ¡ÔñÊʲÅÌí¼ÓµÄ±àÒëÆ÷£¬²¢ÎªÆäÖ¸¶¨Â·¾¶¡£µã»÷”OK”ÉúÑÄÉèÖá£
½¨ÉèÏîÄ¿
ÔÚCLionÖУ¬¿ÉÒÔͨ¹ýÒÔÏÂÁ½ÖÖ·½·¨½¨ÉèÏîÄ¿£º
·½·¨Ò»£º´ÓÒѱ£´æµÄÔ´ÂëÖе¼Èë
ÈôÊÇÒÑÓÐÒ»¸öǶÈëʽÏîÄ¿µÄÔ´´úÂ룬¿ÉÒÔÑ¡Ôñ”Open Project”È»ºóµ¼ÈëÔ´ÂëĿ¼£¬CLion½«×Ô¶¯Ê¶±ðÏîÄ¿µÄCMakeLists.txtÎļþ²¢¾ÙÐÐÉèÖá£
·½·¨¶þ£º´ÓÄ£°å½¨ÉèÐÂÏîÄ¿
ÈôÊÇûÓÐÏֳɵÄÔ´Â룬¿ÉÒÔÑ¡Ôñ”New Project”½¨ÉèÒ»¸öÐÂÏîÄ¿¡£ÔÚÏîÄ¿ÉèÖÃÖÐÑ¡ÔñǶÈëʽ¹¤¾ßÁ´£¬CLion½«»áΪÄã×Ô¶¯ÌìÉúÊʺÏǶÈëʽ¿ª·¢µÄCMakeLists.txtÎļþ¡£
ÉèÖõ÷ÊÔÆ÷
ÔÚ”Run”²Ëµ¥ÏÂÑ¡Ôñ”Edit Configurations”£¬µã»÷”+”ͼ±êÌí¼ÓÒ»¸öеÄÉèÖá£Ñ¡Ôñ”C++ Remote Debug”×÷ΪÉèÖÃÀàÐÍ£¬²¢¾ÙÐÐÒÔÏÂÉèÖãº
Name£ºÉèÖõÄÃû³Æ
Executable£ºÑ¡Ôñ±àÒëºóµÄ¿ÉÖ´ÐÐÎļþ·¾¶
GDB/CDB Debugger£ºÑ¡ÔñºÏÊʵĵ÷ÊÔÆ÷£¨ÀýÈ磬GDB for Linux£©
Connection£ºÉèÖÃÖ÷»úºÍ¶Ë¿Ú£¨ÀýÈ磬localhost:1234£©
µã»÷”OK”ÉúÑÄÉèÖá£
ÔËÐк͵÷ÊÔ
ÔÚCLionÖУ¬¿ÉÒÔͨ¹ýÒÔÏÂÁ½ÖÖ·½·¨ÔËÐк͵÷ÊÔǶÈëʽӦÓóÌÐò£º
·½·¨Ò»£ºÍâµØÔËÐÐ
µã»÷”Run”°´Å¥£¨ÂÌÉ«Èý½ÇÐΣ©£¬CLion½«»áͨ¹ýSSHÅþÁ¬µ½Ä¿µÄ×°±¸£¬È»ºóÔÚÆäÖÐÔËÐÐÓ¦ÓóÌÐò¡£
·½·¨¶þ£ºÔ¶³ÌÔËÐÐ
µã»÷”Run”²Ëµ¥ÏµĔAttach to Local Process”£¬Ñ¡Ôñ֮ǰÉèÖõÄÔ¶³Ìµ÷ÊÔÉèÖá£CLion½«»áͨ¹ýGDBЧÀÍÆ÷ÅþÁ¬µ½Ä¿µÄ×°±¸µÄµ÷ÊÔÆ÷£¬²¢¾ÙÐÐÔ¶³Ìµ÷ÊÔ¡£
ÆäËû³£Óü¼ÇÉ
×Ô¶¯Íê³É£ºCLionÌṩÁËÇ¿Ê¢µÄ´úÂë×Ô¶¯ÍêÀÖ³ÉÄÜ£¬Í¨¹ý¿ì½Ý¼ü£¨ÀýÈçCtrl+Space£©¿ÉÒÔ¿ìËÙ²¹È«´úÂë¡£
´úÂëµ¼º½£ºCLionÖ§³Ö¿ìËÙÌøתµ½½ç˵¡¢Éó²éº¯ÊýŲÓò㼶µÈ¹¦Ð§£¬Í¨¹ý¿ì½Ý¼ü£¨ÀýÈçCtrl+Êó±ê×ó¼ü£©¿ÉÒÔÀû±ãµØ¾ÙÐдúÂëµ¼º½¡£
´úÂëÖع¹£ºCLionÌṩÁ˸»ºñµÄ´úÂëÖع¹¹¦Ð§£¬°üÀ¨ÖØÃüÃû¡¢ÌáÈ¡º¯Êý¡¢ÌáÈ¡±äÁ¿µÈ£¬Í¨¹ý¿ì½Ý¼ü£¨ÀýÈçShift+F6£©¿ÉÒÔÀû±ãµØ¾ÙÐдúÂëÖع¹¡£
°æ±¾¿ØÖÆ£ºCLion¶Ô³£¼ûµÄ°æ±¾¿ØÖÆϵͳ£¨ÈçGit£©ÌṩÁ˼¯³ÉÖ§³Ö£¬¿ÉÒÔÀû±ãµØ¾ÙÐдúÂëÌá½»¡¢ÀÈ¡µÈ²Ù×÷¡£
×ÛÉÏËùÊö£¬CLionÊÇÒ»¿îÇ¿Ê¢¶øÒ×ÓõÄǶÈëʽC/C++¿ª·¢ÇéÐΣ¬ÔÚLinuxϵͳÉϾÙÐÐǶÈëʽ¿ª·¢Ê®·ÖÀû±ã¡£Í¨¹ý׼ȷÉèÖúÍÏàʶCLionµÄһЩ¼¼ÇÉ£¬¿ÉÒÔÌá¸ß¿ª·¢Ð§ÂÊ£¬¼ÓËÙÏîÄ¿µÄ¿ª·¢Àú³Ì¡£
´úÂëʾÀý£º
include
int main() {
printf("Hello, CLion for Embedded Development!
µÇ¼ºó¸´ÖÆ
“);
return 0;
µÇ¼ºó¸´ÖÆ
}
ÒÔÉÏÊÇÒ»¸ö¼òÆÓµÄCÓïÑÔ´úÂëʾÀý£¬ÓÃÓÚÔÚ¿ØÖÆ̨Êä³öÒ»ÌõÐÅÏ¢¡£Í¨¹ýCLionµÄ±à¼Æ÷£¬ÎÒÃÇ¿ÉÒÔÀû±ãµØ±à¼ºÍÔËÐÐÕâÑùµÄǶÈëʽӦÓóÌÐò£¬²¢¾ÙÐе÷ÊԺͲâÊÔ¡£
ÒÔÉϾÍÊÇÔÚLinuxϵͳÉÏʹÓÃCLion¾ÙÐÐǶÈëʽC/C++¿ª·¢µÄÉèÖü¼ÇɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡