-
Notifications
You must be signed in to change notification settings - Fork 13
3. Visual Studio Configuration
Patrick Robichaud edited this page Nov 21, 2017
·
1 revision
Following are some miscellaneous details relating to the configuration of Visual Studio with libraries/DLLs (mainly for OpenCV, applicable to other libraries as well).
- OpenCV include/library relative paths
- dll storage and post build copy to execution folder.
The following paths must be set to include necessary headers and libraries in the Project Property Pages window as follows.
Right click on Project -> Properties -> Configuration Properties
Include File (Header) Path
C/C++ -> General -> Additional Include Directories: $(ProjectDir)..\..\opencv\include
VC++ Directories -> Include Directories: $(ProjectDir)..\..\opencv\include
Library Path
VC++ Directories -> Library Directories: $(ProjectDir)..\..\opencv\x64\vc14\lib
Linker -> General -> Additional Library Directories: $(ProjectDir)..\..\opencv\x64\vc14\lib;
**Library Files
Linker -> Input -> Additional Dependencies: opencv_core330d.lib; opencv_highgui330d.lib;opencv_imgcodecs330d.lib; opencv_imgproc330d.lib; opencv_objdetect330d.lib; opencv_features2d330d.lib; opencv_videoio330d.lib
Libraries are checked at compile time, but DLLs are loaded at RUNTIME* and must be in the same folder as the .exe. Thus, any necessary DLLs must be copied to the build folder (BlindAid\x64\Debug or Release) using Post Build Events.
Build Events -> Post Build Events -> Command Line: xcopy /d /y /s /r "$(ProjectDir)\..\..\Dependencies\opencv\x64\vc14\bin\*.dll" "$(OutDir)"
The post build event above uses the following variables that point to locations in the project.
$(ProjectDir): Folder containing all the .cpp/.h files for the current project.
$(OutDir): Folder where the .exe is compiled to in the current configuration (x86/x64 & Debug/Release).
..\: Goes up one folder (useful for referring to TestData in loading/Dependencies in config).
*: Wildcard in file/folder names (also to select all subfolders and files).