cmakelists.txt 新增opencv 動態庫
cmake_minimum_required (version 2.8)
# 專案資訊
project (server)
set(cmake_c_compiler g++)
add_compile_options(-std=c++11)
# 查詢當前目錄下的所有原始檔
# 並將名稱儲存到 dir_srcs 變數
aux_source_directory(. dir_srcs)
message(status "this is binary dir " $)
message(status "this is source dir "$)
# 生成debug版本
#set(cmake_build_type "release")
#set(cmake_cxx_flags_debug "$env -o0 -wall -g -ggdb")
#set(cmake_cxx_flags_release "$env -o3 -wall")
# 新增第三方的庫
set(inc_dir $/third_lib/include/) # 找到自己的路徑
set(link_dir $/third_lib/lib) # 找到自己的路徑
include_directories($)
link_directories($)
link_libraries(opencv_world)
# 指定生成目標
add_executable(server $)
# 將第三方的庫鏈結到可執行檔案
target_link_libraries(server opencv_world)
#target_link_libraries(future_net dl)
#target_link_libraries(future_net pthread)
cmakelists.txt 新增opencv 靜態庫
cmake_minimum_required (version 2.8)
# 專案資訊
project (server)
set(cmake_c_compiler g++)
add_compile_options(-std=c++11)
# 查詢當前目錄下的所有原始檔
# 並將名稱儲存到 dir_srcs 變數
aux_source_directory(. dir_srcs)
message(status "this is binary dir " $)
message(status "this is source dir "$)
# 新增第三方的庫
set(inc_dir /local_install/static/include)
#set(link_dir /local_install/static/lib)
set(thirdparty_root /local_install)
set(libs $/static/lib/libopencv_imgcodecs.a $/static/lib/libopencv_dnn.a
$/static/lib/libopencv_imgproc.a $/static/lib/libopencv_core.a
$/static/share/opencv/3rdparty/lib/liblibjpeg.a $/static/share/opencv/3rdparty/lib/liblibpng.a
$/static/share/opencv/3rdparty/lib/libippicv.a $/static/share/opencv/3rdparty/lib/libilmimf.a
$/static/share/opencv/3rdparty/lib/liblibjasper.a $/static/share/opencv/3rdparty/lib/liblibtiff.a
$/static/share/opencv/3rdparty/lib/liblibwebp.a $/static/share/opencv/3rdparty/lib/libzlib.a)
message(status "libs= "$)
#add_library(mylib static $)
#set(cmake_cxx_flags_debug "$env -o0 -wall -g -ggdb")
set(cmake_cxx_flags_release "$env -o3 -wall")
include_directories($)
#link_directories($)
link_libraries($)
# 指定生成目標
add_executable(server $)
# 將第三方的庫鏈結到可執行檔案
target_link_libraries(server $)
target_link_libraries(server dl)
target_link_libraries(server pthread)
cmake新增動態鏈結庫
如果使用gcc進行單個c檔案編譯的時候,有時候後面會需要新增如 l l之類的引數,如下 gcc o test test.c l usr local lib lopencv 這裡 l是制定動態庫的位置,l則是指定打算連線的動態庫名字。那麼在進行專案編譯的時候就需要通過cmake來通過cmakelist...
cmake編譯opencv專案
其他方法與優缺點 example.cpp include include using namespace cv using namespace std intmain int argc,char ar imshow demo src waitkey 0 return0 在專案檔案中新建cmakeli...
Cmake自動配置openCV
然後,還要確保你的機子已經安裝了一種編譯器,我機子上安裝的是vs2010。你也可以選擇其他編譯器,建議用vs2008或以上版本的,個人覺得比較好用。接著在你機子的某個盤裡建乙個新的資料夾,如我這裡的完整路徑是 d cmake cmake study hellocmake 然後在hellocmake資...