以前,windows下配置opencv一直不太方便:總是要手動新增lib,新增include,還要配置path使得程式執行時候能找到dll檔案。
每次新建乙個使用opencv的工程都要手動新增,很麻煩;而且,有時候需要不同版本的opencv測試。如果從32位模式切換到64位模式,又需要替換一次配置。。一旦有乙個配錯了,就總是徘徊在各種配置項的檢查上。
後來,看到了freedomshe用屬性表進行配置,其提供的屬性表檔案確實方便,但是還是需要手動配置opencv環境變數、追加opencv中的bin目錄到path上(bin中有dll檔案)。能不能不配置?(免得保不准自己又要重啟機器...)
答案當然是可以!
配置opencv環境變數的目的在於,include路徑、lib路徑都使用這個字首,能減少打字的次數;同時也是要把opencv的幾個dll檔案所在路徑,追加到系統path上。
只要我們在屬性表檔案中自行定義opencv根目錄,新增include路徑、lib路徑,新增dll目錄,以後使用opencv的專案只需要匯入這個屬性表就ok了,太簡單了!
當然,以前的老版本中的各種dll和lib分成好多個檔案,現在的版本如果編譯了opencv_contrib
也會有額外的dll和lib,這些需要的時候再新增就好了。
廢話不多說,這是opencv3.0.0的通用屬性表檔案opencv300.props
<?xml version="1.0" encoding="utf-8"?>
f:\chris\lib\opencv-3.1.0\buildextra\install
$(opencvroot)\include;$(includepath)
$(opencvroot)\x86\vc12\lib;$(librarypath)
$(opencvroot)\x64\vc12\lib;$(librarypath)
$(projectdir)
windowslocaldebugger
path=%path%;$(opencvroot)\x86\vc12\bin
path=%path%;$(opencvroot)\x64\vc12\bin
opencv_ts300d.lib;opencv_world310d.lib;%(additionaldependencies)
opencv_ts300.lib;opencv_world310.lib;%(additionaldependencies)
如果是opencv3.1那麼lib只需要配置opencv_world310,對應的屬性表檔案為:
<?xml version="1.0" encoding="utf-8"?>
d:\lib\opencv310\build
$(opencvroot)\include;$(includepath)
$(opencvroot)\x86\vc12\lib;$(librarypath)
$(opencvroot)\x64\vc12\lib;$(librarypath)
$(projectdir)
windowslocaldebugger
path=%path%;$(opencvroot)\x86\vc12\bin
path=%path%;$(opencvroot)\x64\vc12\bin
opencv_world310d.lib;%(additionaldependencies)
opencv_world310.lib;%(additionaldependencies)
當然有時候需要使用opencv_contrib,那麼編譯好contrib後就增加了很多dll和lib,對應的屬性表檔案是這樣的(opencv3.1版):
<?xml version="1.0" encoding="utf-8"?>
f:\chris\lib\opencv-3.1.0\buildextra\install
$(opencvroot)\include;$(includepath)
$(opencvroot)\x86\vc12\lib;$(librarypath)
$(opencvroot)\x64\vc12\lib;$(librarypath)
$(projectdir)
windowslocaldebugger
path=%path%;$(opencvroot)\x86\vc12\bin
path=%path%;$(opencvroot)\x64\vc12\bin
opencv_aruco310d.lib;opencv_bgsegm310d.lib;opencv_bioinspired310d.lib;opencv_calib3d310d.lib;opencv_ccalib310d.lib;opencv_core310d.lib;opencv_cudaarithm310d.lib;opencv_cudabgsegm310d.lib;opencv_cudacodec310d.lib;opencv_cudastereo310d.lib;opencv_cudawarping310d.lib;opencv_cudev310d.lib;opencv_datasets310d.lib;opencv_dnn310d.lib;opencv_dpm310d.lib;opencv_face310d.lib;opencv_features2d310d.lib;opencv_flann310d.lib;opencv_fuzzy310d.lib;opencv_highgui310d.lib;opencv_imgcodecs310d.lib;opencv_imgproc310d.lib;opencv_line_descriptor310d.lib;opencv_ml310d.lib;opencv_objdetect310d.lib;opencv_optflow310d.lib;opencv_plot310d.lib;opencv_reg310d.lib;opencv_rgbd310d.lib;opencv_saliency310d.lib;opencv_shape310d.lib;opencv_stereo310d.lib;opencv_structured_light310d.lib;opencv_su***ce_matching310d.lib;opencv_text310d.lib;opencv_tracking310d.lib;opencv_ts310d.lib;opencv_video310d.lib;opencv_videoio310d.lib;opencv_world310d.lib;opencv_ximgproc310d.lib;opencv_xobjdetect310d.lib;%(additionaldependencies)
opencv_aruco310.lib;opencv_bgsegm310.lib;opencv_bioinspired310.lib;opencv_calib3d310.lib;opencv_ccalib310.lib;opencv_core310.lib;opencv_cudaarithm310.lib;opencv_cudabgsegm310.lib;opencv_cudacodec310.lib;opencv_cudastereo310.lib;opencv_cudawarping310.lib;opencv_cudev310.lib;opencv_datasets310.lib;opencv_dnn310.lib;opencv_dpm310.lib;opencv_face310.lib;opencv_features2d310.lib;opencv_flann310.lib;opencv_fuzzy310.lib;opencv_highgui310.lib;opencv_imgcodecs310.lib;opencv_imgproc310.lib;opencv_line_descriptor310.lib;opencv_ml310.lib;opencv_objdetect310.lib;opencv_optflow310.lib;opencv_plot310.lib;opencv_reg310.lib;opencv_rgbd310.lib;opencv_saliency310.lib;opencv_shape310.lib;opencv_stereo310.lib;opencv_structured_light310.lib;opencv_su***ce_matching310.lib;opencv_text310.lib;opencv_tracking310.lib;opencv_ts310.lib;opencv_video310.lib;opencv_videoio310.lib;opencv_world310.lib;opencv_ximgproc310.lib;opencv_xobjdetect310.lib;%(additionaldependencies)
**********=
p.s. 有人可能會問,上面的屬性表xml檔案裡面的各屬性是如何確定的?屬性值容易設定,屬性名確實不是一眼看出來的。
可以通過新建乙個工程,在工程的屬性中手動設定vc++、c/c++、鏈結器等條目中的項,進行設定後vs2013會寫入到/.vcxproj.user這個檔案中。手動在gui介面中設定了需要的屬性後,檢視.vcxproj.user檔案,把需要的屬性剪下到屬性表檔案中,以後同型別的工程就可以僅僅使用此屬性表檔案進行配置了。比如dll的路徑,通過當前工程的屬性->除錯->工作目錄進行設定:
mongo c driver使用VS2013編譯
git clonegit clone mongo c driver win64 bin.7z 這裡先需要使用cmake工具來生成vs2013的專案檔案。如果沒有安裝cmake,請先安裝。進入mongo c driver src libbson目錄,開啟命令列視窗,執行以下命令 mkdir msvc1...
VS2013 配置遠端除錯
一 環境 主機host 虛擬機器 or 主機a 主機b 兩台物理機 vs2013 一般放在物理機上 注意 不管是哪種情況,兩台主機必須位於同乙個區域網之內 除錯虛擬機器中的exe時,虛擬機器要採用橋接方式訪問網路 網路配置示例 主機ip 虛擬機器ip 虛擬機器配置如下 a 將vs2013安裝目錄下的...
VS2013配置opencv環境
1 進入工程屬性頁,開啟 配置屬性 頁 2 在 vc 目錄 頁面下,包含目錄 中新增opencv安裝目錄的以下目錄 d opencv build include d opencv build include opencv d opencv build include opencv2 3 在 vc 目...