尊龙凯时人生就是搏

ʹÓÃCMake¹¹½¨LinuxÈ˹¤ÖÇÄÜÓ¦ÓóÌÐòµÄÉèÖü¼ÇÉ

ʹÓÃcmake¹¹½¨linuxÈ˹¤ÖÇÄÜÓ¦ÓóÌÐòµÄÉèÖü¼ÇÉ

È˹¤ÖÇÄÜ£¨Artificial Intelligence£¬¼ò³ÆAI£©ÊÖÒÕÔÚµ±½ñÌìϵĸ÷¸öÁìÓò»ñµÃÁËÆÕ±éµÄÓ¦Ó㬲¢ÇÒÆäÓ¦ÓõÄÐèÇóÒ²Ò»Ö±ÔöÌí¡£ÔÚLinuxƽ̨ÉÏ£¬Ê¹ÓÃCMake×÷ΪÏîÄ¿¹¹½¨¹¤¾ß¿ÉÒÔ×ÊÖúÎÒÃǸüºÃµØÖÎÀíºÍÉèÖÃÈ˹¤ÖÇÄÜÓ¦ÓóÌÐò¡£±¾ÎĽ«ÏÈÈÝһЩʹÓÃcmake¹¹½¨linuxÈ˹¤ÖÇÄÜÓ¦ÓóÌÐòµÄÉèÖü¼ÇÉ£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£

Ò»¡¢×°ÖÃCMake

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚLinuxϵͳÉÏ×°ÖÃCMake¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°ÖÃCMake£º

sudo apt-get update
sudo apt-get install cmake

µÇ¼ºó¸´ÖÆ

¶þ¡¢½¨ÉèCMakeLists.txtÎļþ

ÔÚÏîÄ¿µÄ¸ùĿ¼Ï½¨ÉèÒ»¸öÃûΪCMakeLists.txtµÄÎļþ£¬¸ÃÎļþÊÇCMakeµÄÉèÖÃÎļþ£¬ÓÃÓÚÐÎòÏîÄ¿µÄ¹¹½¨¹æÔòºÍÒÀÀµ¹Øϵ¡£

cmake_minimum_required(VERSION 3.14)
project(AIApp)

# ÉèÖÃC++±ê×¼
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# ÉèÖÃÔ´ÎļþÁбí
set(SOURCES main.cpp ai_module.cpp)

# Ìí¼Ó¿ÉÖ´ÐÐÎļþ
add_executable(AIApp ${SOURCES})

# Ìí¼ÓÒÀÀµ¿â£¨Ê¾ÀýÖ»°üÀ¨Ò»¸öOpenCV¿â£©
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(AIApp ${OpenCV_LIBS})

µÇ¼ºó¸´ÖÆ

ÉÏÊöʾÀýÉèÖÃÎļþÖУ¬Ê×ÏÈÖ¸¶¨ÁËCMakeÐèÒªµÄ×îµÍ°æ±¾ÐÅÏ¢¡£È»ºó£¬ÉèÖÃÁËC++µÄ±ê׼ΪC++11£¬²¢ÒªÇó±àÒëÆ÷Öª×ã¸Ã±ê×¼µÄÒªÇó¡£

½ÓÏÂÀ´£¬½ç˵ÁËÔ´ÎļþµÄÁÐ±í£¬ÕâÀïÖ»ÁгöÁËÁ½¸öÔ´Îļþ£¨main.cppºÍai_module.cpp£©£¬ÏÖʵÏîÄ¿ÖпÉÄÜ»áÓиü¶àµÄÔ´Îļþ¡£

ʹÓÃadd_executableÏÂÁîÌí¼ÓÁËÒ»¸öÃûΪAIAppµÄ¿ÉÖ´ÐÐÎļþ£¬²¢½«Ö®Ç°½ç˵µÄÔ´ÎļþÁбíת´ï¸ø¸ÃÏÂÁî¡£

ͨ¹ýfind_packageÏÂÁî²éÕÒOpenCV¿â£¬²¢Ê¹ÓÃinclude_directories½«¿âµÄÍ·ÎļþĿ¼Ìí¼Óµ½±àÒëÆ÷µÄËÑË÷·¾¶ÖС£×îºó£¬Ê¹ÓÃtarget_link_librariesÏÂÁOpenCV¿âÓëAIAppÁ´½ÓÆðÀ´¡£

Èý¡¢¹¹½¨ºÍÔËÐÐ

ÔÚÏîÄ¿µÄ¸ùĿ¼ÏÂÖ´ÐÐÒÔÏÂÏÂÁîÀ´¹¹½¨È˹¤ÖÇÄÜÓ¦ÓóÌÐò£º

mkdir build
cd build
cmake ..
make

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÊ×ÏȽ¨ÉèÁËÒ»¸öÃûΪbuildµÄĿ¼£¬²¢½øÈë¸ÃĿ¼¡£È»ºóʹÓÃcmakeÏÂÁîƾ֤CMakeLists.txtÎļþÌìÉúÓÃÓÚ¹¹½¨µÄMakefile¡£×îºóʹÓÃmakeÏÂÁî¾ÙÐбàÒëºÍÁ´½Ó¡£

±àÒëÍê³Éºó£¬ÔÚbuildĿ¼Ï»áÌìÉú¿ÉÖ´ÐÐÎļþAIApp¡£¿ÉÒÔÖ±½ÓÔËÐиÿÉÖ´ÐÐÎļþÀ´Ê¹ÓÃÈ˹¤ÖÇÄÜÓ¦ÓóÌÐò¡£

ËÄ¡¢ÆäËûÉèÖÃÑ¡Ïî

³ýÁËÉÏÊöµÄ»ù±¾ÉèÖÃÍ⣬CMake»¹ÌṩÁËһЩÆäËûµÄÉèÖÃÑ¡Ï¿ÉÒÔƾ֤ÏÖʵÐèÒª¾ÙÐе÷½â¡£ÒÔÏÂÊÇһЩ³£ÓõÄÉèÖÃÑ¡ÏîʾÀý£º

ÉèÖÃÊä³ö·¾¶

ͨ¹ýÖ¸¶¨CMAKE_BUILD_TYPE±äÁ¿¿ÉÒÔÉèÖÃÊä³öÎļþµÄ·¾¶¡£¿ÉÒÔÔÚCMakeLists.txtÎļþÖÐÌí¼ÓÒÔÏÂÐУº

set(CMAKE_BUILD_TYPE Release)

µÇ¼ºó¸´ÖÆ

ÉÏÊöʾÀý½«Êä³öÎļþ·ÅÔÚ¸ùĿ¼ÏµÄreleaseĿ¼ÖС£¿ÉÒÔƾ֤ÐèÇóÉèÖÃΪDebug¡¢Release»òÆäËû×Ô½ç˵µÄÖµ¡£

Ìí¼Ó±àÒëÑ¡Ïî

¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¸ø±àÒëÆ÷Ìí¼ÓÑ¡Ï

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3")

µÇ¼ºó¸´ÖÆ

ÉÏÊöʾÀýÌí¼ÓÁ˱àÒëÆ÷µÄÖÒÑÔÐÅÏ¢Êä³öºÍÓÅ»¯Ñ¡Ïî¡£

Ìí¼ÓµÚÈý·½ÒÀÀµ¿â

¹ØÓÚһЩ³£ÓõĵÚÈý·½ÒÀÀµ¿â£¬CMakeÒѾ­ÌṩÁËÏìÓ¦µÄÄ£¿é£¨Module£©¾ÙÐвéÕÒºÍÉèÖá£Ê¾ÀýÈçÏ£º

find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(AIApp ${OpenCV_LIBS})

µÇ¼ºó¸´ÖÆ

ÉÏÊöʾÀýʹÓÃÁËOpenCV¿â£¬²¢Í¨¹ýfind_packageÏÂÁîÕÒµ½Á˸ÿ⡣Ȼºóͨ¹ýinclude_directories½«Í·ÎļþĿ¼Ìí¼Óµ½±àÒëÆ÷µÄËÑË÷·¾¶ÖУ¬ÔÙͨ¹ýtarget_link_librariesÏÂÁ¿âÓë¿ÉÖ´ÐÐÎļþÁ´½Ó¡£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËʹÓÃcmake¹¹½¨linuxÈ˹¤ÖÇÄÜÓ¦ÓóÌÐòµÄÉèÖü¼ÇÉ£¬²¢ÌṩÁËÏìÓ¦µÄ´úÂëʾÀý¡£Í¨¹ýCMakeµÄÉèÖÃÎļþCMakeLists.txt£¬ÎÒÃÇ¿ÉÒÔ¸üÀû±ãµØÖÎÀíºÍÉèÖÃÏîÄ¿µÄ¹¹½¨¹æÔòºÍÒÀÀµ¹Øϵ¡£Ï£ÍûÕâЩ¼¼ÇɹØÓÚ¿ª·¢Ö°Ô±ÔÚLinuxƽ̨ÉϹ¹½¨È˹¤ÖÇÄÜÓ¦ÓóÌÐòʱÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇʹÓÃCMake¹¹½¨LinuxÈ˹¤ÖÇÄÜÓ¦ÓóÌÐòµÄÉèÖü¼ÇɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Á¢³¡£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ