[JetBrains-CLion jihuo教程](https://www.techgrow.cn/posts/c0477083.html)(20200917可用)
一直使用pycharm,所以还是继续使用他们家产品!
与opencv结合
[Ubuntu Clion使用Cmake 配置 opencv开发。系列一](https://www.jianshu.com/p/3d1f7cbeeb35)
CMakeLists.txt,自己把test换成程序名
cmake_minimum_required(VERSION 3.15)
project(test)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES main.cpp)
add_executable(test main.cpp)
target_link_libraries(test ${OpenCV_LIBS})
cpp依赖时,运行的CMakeLists.txt如下:
cmake_minimum_required(VERSION 3.15)
project(test4)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 14) # C++运行版本
#set(SOURCE_FILES main.cpp)
#add_executable(test4 main.cpp temp1.cpp)
#target_link_libraries(test4 ${OpenCV_LIBS})
# 遍历项目根目录下所有的 .cpp 文件
file (GLOB files *.cpp)
foreach (file ${files})
string(REGEX REPLACE ".+/(.+)\\..*" "\\1" exe ${file})
add_executable (${exe} ${file} common.cpp imgDeduplication.cpp) # 使用的cpp文件编译,可以不用加.h文件
message (\ \ \ \ --\ ${exe}.cpp\ will\ be\ compiled\ to\ ${exe})
target_link_libraries(${exe} ${OpenCV_LIBS} -lglog -ljsoncpp -lboost_system) # 链接库
endforeach ()
遍历项目根目录下所有的 .cpp 文件
file (GLOB files *.cpp)
foreach (file ${files})
string(REGEX REPLACE ".+/(.+)\\..*" "\\1" exe ${file})
add_executable (${exe} ${file} common.cpp imgDeduplication.cpp) # 使用的cpp文件编译,可以不用加.h文件
message (\ \ \ \ --\ ${exe}.cpp\ will\ be\ compiled\ to\ ${exe})
target_link_libraries(${exe} ${OpenCV_LIBS} -lglog -ljsoncpp -lboost_system) # 链接库
endforeach ()
cmake输出
-- OpenCV library status:
-- version: 3.4.5
-- libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab
-- include path: /usr/local/include;/usr/local/include/opencv
有时需要多开,不想在建新项目,找到参考
如何在 clion 运行多个 main 函数
自己需要调用opencv,所以CMakeLists.txt如下:
cmake_minimum_required(VERSION 3.15)
project(test4)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 14)
#set(SOURCE_FILES main.cpp)
#add_executable(test4 main.cpp temp1.cpp)
#target_link_libraries(test4 ${OpenCV_LIBS})
# 遍历项目根目录下所有的 .cpp 文件
file (GLOB files *.cpp)
foreach (file ${files})
string(REGEX REPLACE ".+/(.+)\\..*" "\\1" exe ${file})
add_executable (${exe} ${file})
message (\ \ \ \ --\ src/${exe}.cpp\ will\ be\ compiled\ to\ bin/${exe})
target_link_libraries(${exe} ${OpenCV_LIBS})
endforeach ()
what(): OpenCV(3.4.5) /home/czey/Downloads/3.4.5/opencv-3.4.5/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
不知道为何识别到这里,我没有设置啊???先mark下(知道了,没有输入数据,要设置输入参数)