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`

你可能感兴趣的:(makefile)