ʹÓÃCLion¾ÙÐÐLinux C/C++¿ª·¢µÄ»ù±¾ÉèÖÃÖ¸ÄÏ
ʹÓÃclion¾ÙÐÐlinux c/c++¿ª·¢µÄ»ù±¾ÉèÖÃÖ¸ÄÏ
CLionÊÇÒ»¿îÓÉJetBrains¿ª·¢µÄ¼¯³É¿ª·¢ÇéÐΣ¨IDE£©£¬×¨ÃÅÓÃÓÚCºÍC++ÓïÑԵĿª·¢¡£ÔÚLinuxϵͳÉÏ£¬CLionÌṩÁËÇ¿Ê¢µÄ´úÂë±à¼¡¢µ÷ÊԺ͹¹Á¢¹¦Ð§£¬Ê¹±à³ÌÊÂÇéÔ½·¢¸ßЧºÍ±ã½Ý¡£±¾ÎĽ«ÏÈÈÝÔõÑù»ù±¾ÉèÖÃCLion£¬Ê¹ÆäÊÊÓÃÓÚLinux C/C++¿ª·¢£¬²¢¸½´øһЩ´úÂëʾÀý¡£
µÚÒ»²½£º×°ÖÃCLion
Ê×ÏÈ£¬´ÓJetBrains¹ÙÍøÏÂÔØÊÊÓÃÓÚLinuxϵͳµÄCLion×°Öðü£¬²¢Æ¾Ö¤×°ÖÃÏòµ¼¾ÙÐÐ×°Öá£×°ÖÃÍê³Éºó£¬Æô¶¯CLion¡£
µÚ¶þ²½£º½¨ÉèÒ»¸öÐÂÏîÄ¿
ÔÚCLionµÄ½Ó´ý½çÃ棬µã»÷”Create New Project”À´½¨ÉèÒ»¸öÐÂÏîÄ¿¡£Ñ¡Ôñ”C Executable”»ò”C++ Executable”×÷ΪÏîÄ¿ÀàÐÍ£¬È»ºóµã»÷”Next”¼ÌÐø¡£
µÚÈý²½£ºÉèÖñàÒëÆ÷
ÔÚÏîÄ¿ÉèÖýçÃ棬ѡÔñÊÊÓÃÓÚÄãµÄϵͳµÄ±àÒëÆ÷¡£Ò»Ñùƽ³£ÇéÐÎÏ£¬GCCÊÇLinuxϵͳµÄĬÈϱàÒëÆ÷£¬¿ÉÒÔÑ¡ÔñGCC×÷Ϊ±àÒëÆ÷¡£ÈôÊÇÄãÒѾװÖÃÁËÆäËû±àÒëÆ÷£¬Ò²¿ÉÒÔÑ¡ÔñÆäËü±àÒëÆ÷¡£µã»÷”Next”¼ÌÐø¡£
Á¬Ã¦Ñ§Ï°¡°C++Ãâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
µÚËIJ½£ºÉèÖÃÏîĿ·¾¶
ÔÚÏîÄ¿ÉèÖýçÃ棬ѡÔñÊÊÓÃÓÚÄãµÄÏîÄ¿µÄ·¾¶¡£¿ÉÒÔÑ¡ÔñÏÖÓеÄĿ¼£¬»òÕß½¨ÉèÒ»¸öÐÂĿ¼À´´æ·ÅÏîÄ¿Îļþ¡£µã»÷”Finish”Íê³ÉÏîÄ¿µÄ½¨Éè¡£
µÚÎå²½£º±àд´úÂë
ÔÚCLionµÄ±à¼½çÃ棬¿ÉÒÔ×îÏȱàдC/C++´úÂë¡£CLionÌṩÁËÖÇÄÜ´úÂ벹ȫ¡¢Óï·¨¼ì²éºÍ×Ô¶¯ÃûÌû¯µÈ¹¦Ð§£¬Ê¹±à³ÌÔ½·¢¸ßЧ¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄC´úÂëʾÀý£º
#include <stdio.h> int main() { printf("Hello, World! "); return 0; }
µÇ¼ºó¸´ÖÆ
µÚÁù²½£º¹¹½¨ºÍÔËÐÐ
ÔÚCLionµÄ¹¤¾ßÀ¸ÖУ¬ÓÐÒ»¸ö½Ð×ö”Build”µÄ°´Å¥£¬µã»÷Õâ¸ö°´Å¥¿ÉÒÔ¶ÔÏîÄ¿¾ÙÐй¹½¨¡£¹¹½¨Íê³Éºó£¬¿ÉÒÔµã»÷”Run”°´Å¥À´ÔËÐÐÏîÄ¿¡£CLionÌṩÁ˵÷ÊÔ¹¦Ð§£¬¿ÉÒÔͨ¹ýÉèÖöϵãºÍÊÓ²ì±äÁ¿µÄÖµ£¬À´µ÷ÊÔ³ÌÐò¡£
µÚÆß²½£ºÌí¼ÓÍⲿ¿â
ÈôÊÇÄãµÄÏîÄ¿ÐèҪʹÓÃÍⲿ¿â£¬¿ÉÒÔÔÚCLionÖÐÉèÖÃÏîÄ¿µÄÒÀÀµ¡£ÔÚÏîÄ¿ÉèÖýçÃæµÄ”Build, Execution, Deployment -> CMake -> Build”Ñ¡ÏÖУ¬¿ÉÒÔÌí¼ÓÍⲿ¿âµÄ·¾¶ºÍÒÀÀµ¡£ÀýÈ磬ÈôÊÇÄãµÄÏîĿʹÓÃÁËOpenCV¿â£¬¿ÉÒÔÌí¼ÓOpenCV¿âµÄ·¾¶ºÍÁ´½Ó¡£
# CMakeLists.txt cmake_minimum_required(VERSION 3.17) project(MyProject) set(CMAKE_CXX_STANDARD 14) # Ìí¼ÓOpenCV¿âµÄ·¾¶ºÍÁ´½Ó set(OpenCV_DIR <path_to_opencv>) find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) add_executable(MyProject main.cpp) target_link_libraries(MyProject ${OpenCV_LIBS})
µÇ¼ºó¸´ÖÆ
×ܽ᣺
ͨ¹ýÉÏÊö°ì·¨£¬¿ÉÒÔ»ù±¾ÉèÖÃCLion¾ÙÐÐLinux C/C++¿ª·¢¡£CLionÌṩÁ˸»ºñµÄ¹¦Ð§ºÍ¹¤¾ß£¬×ÊÖú¿ª·¢ÕßÌá¸ß¿ª·¢Ð§ÂÊ¡£Í¬Ê±£¬CLionÒ²Ö§³Ö°æ±¾¿ØÖƹ¤¾ß£¬ÈçGit£¬Àû±ãÍŶÓÐ×÷ºÍÏîÄ¿ÖÎÀí¡£Ï£Íû±¾ÎÄÄܶÔÐÂÊÖ¿ª·¢ÕßÌṩһЩ×ÊÖú£¬Ê¹ËûÃÇÔ½·¢ÇáËɵؾÙÐÐLinux C/C++¿ª·¢¡£
ÒÔÉϾÍÊÇʹÓÃCLion¾ÙÐÐLinux C/C++¿ª·¢µÄ»ù±¾ÉèÖÃÖ¸ÄϵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡