zoukankan      html  css  js  c++  java
  • opencv的CMakeLists.txt与makefile写法

    opencv的CMakeLists.txt

    cmake_minimum_required(VERSION 2.8)
    project(my_run_name)
    find_package(OpenCV REQUIRED)
    add_executable(your_executable_file test_imgread.cpp)
    target_link_libraries(videostab ${OpenCV_LIBS})
    

    linux下使用opencv的cpp代码,对应的makefile

    有imread.cpp和fun2.cpp,以及fun2.h三个文件

    all: out
    
    out: imread.o fun2.o
    	g++ -o nice imread.o fun2.o `pkg-config --libs opencv`
    
    imgread.o: imread.cpp
    	g++ -c imread.cpp `pkg-config --cflags opencv`
    
    fun2.o: fun2.cpp
    	g++ -c fun2.cpp `pkg-config --cflags opencv`
    
    

    如果是用CLion作为IDE,则其CMakeLists.txt写成:

    cmake_minimum_required(VERSION 3.2)
    project(opencv_test)
    
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    
    set(SOURCE_FILES main.cpp)
    find_package(OpenCV REQUIRED)
    add_executable(opencv_test ${SOURCE_FILES} source_file.h source_file.cpp)
    target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
    

    也就是添加了倒数第1行和倒数第3行。

    Greatness is never a given, it must be earned.
  • 相关阅读:
    发送邮件
    php防止表单重复提交
    mysql 优化之注意
    mysqldump
    项目中下拉框链接问题
    css在IE和Firefox下的兼容性
    利用curl并发来提高页面访问速度
    修改linux下mysql目录权限
    ajax跨域
    wireshark抓包
  • 原文地址:https://www.cnblogs.com/zjutzz/p/4671466.html
Copyright © 2011-2022 走看看