下面是一个Opencv依赖库的添加:
cmake_minimum_required( VERSION 2.8 )
project( imageBasics )
# 添加c++ 11标准支持
set( CMAKE_CXX_FLAGS "-std=c++11" )
# 寻找OpenCV库
set(OpenCV_DIR /home/chaofan/opt/opencv-3.4.4/release)
find_package( OpenCV 3 REQUIRED )
# 添加头文件
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( imageBasics imageBasics.cpp )
# 链接OpenCV库
target_link_libraries( imageBasics ${OpenCV_LIBS} )
上面说明了添加依赖库的主要步骤:
第一个: 添加头文件
第二个:找到源文件
第三个:与目标链接起来
一、生成.so共享库文件
下面是我的几个文件:
1hello.cpp
//hello.cpp
int Calculate_sum_Of_Two_Number(int x,int y)
{
int z=0;
z=x+y;
return (z);
}
2hello.hpp
//hello.hpp
#ifndef __HELLO_H
#define __HELLO_H
int Calculate_sum_Of_Two_Number(int x,int y);
#endif
3 main.cpp
//main.cpp
#include