Visual studio project¶
Instructions¶
Note that this instructions assume that all libraries are installed in C:\CppLib\ which of course is not necessary, but for clarity full paths are always provided so that the directory structure is clear.
- Download OpenCV library installer ( Latest working version) (OpenCV-2.4.2.exe)
- Download CMake Win32 Installer ( Latest working version) (cmake-2.8.8-win32-x86.exe)
- Download TBB library (tbb40_20120613oss_win.zip)
- Download QT library (QtSdk-online-win-x86-v1_2_1.exe)
- Download Irrlicht library (irrlicht-1.7.3.zip)
- Download Directx SDK (DXSDK_Jun10.exe)
- Download Boost library (boost_1_50_0.7z)
- Install CMake
- Install QT SDK (Only the component Qt 4.8.1 MSVC 2010 is necessary) (C:\CppLib\Qt\)
- Install DirectX SDK (make sure to check Headers and libs, Symbol Files, Runtime Support, Utilities) (C:\CppLib\DirectXSDK-June2010)
- Extract TBB (C:\CppLib\tbb40_20120613oss)
- Build OpenCV (it is advisable to recompile both 32bit and 64bit binaries since the shipped version often causes random crashes)
- Install OpenCV to C:\CppLib\OpenCV-2.4.2_64bit - directory needs to end with _64bit ! (because of VRUT settings)
- Move contents of opencv directory one directory up (so that it exists C:\CppLib\OpenCV-2.4.2_64bit\build)
- Run CMake (cmake-gui)
- Set Where is the source code to C:/CppLib/OpenCV-2.4.2_64bit/ (OpenCV installation directory)
- Set Where to build the binaries to C:/CppLib/OpenCV-2.4.2_64bit/build/'''x86'''/vc10/proj
- Configure
- Set Specify generator for this project = Visual Studio 10 (ie. Visual Studio 2010) and Use default native compilers
- Check WITH_QT and WITH_TBB uncheck BUILD_opencv_python and WITH_CUDA
- Configure
- Set QT_QMAKE_EXECUTABLE to C:/CppLib/Qt/Desktop/Qt/4.8.1/msvc2010/bin/qmake.exe
- Set TBB_INCLUDE_DIRS to C:/CppLib/tbb40_20120613oss/include
- Configure, Configure
- If nothing is red, then Generate
- Open C:\CppLib\OpenCV-2.4.2_64bit\build\x86\vc10\proj\OpenCV.sln in Visual Studio
- Select configuration Debug and project ALL_BUILD and Build
- Select configuration Release and ALL_BUILD and Build
- Run copyOpenCV.cmd in directory proj (C:\CppLib\OpenCV-2.4.2_64bit\build\x86\vc10\proj\)
- Back to CMake and set Where to build the binaries to C:/CppLib/OpenCV-2.4.2_64bit/build/'''x64'''/vc10/proj
- Configure
- Specify generator for this project = Visual Studio 10 Win64 (ie. Visual studio 2010) and Use default native compilers
- Check WITH_TBB uncheck WITH_CUDA and WITH_QT (Qt does not work for 64bit)
- Configure
- Set TBB_INCLUDE_DIRS to C:/CppLib/tbb40_20120613oss/include (same as for 32bit version)
- Configure, Configure
- If nothing is red, then Generate
- Open C:\CppLib\OpenCV-2.4.2_64bit\build\x64\vc10\proj\OpenCV.sln in Visual studi
- Select configuration Debug and project ALL_BUILD and build
- Select configuration Release and project ALL_BUILD and build
- Run copyOpenCV.cmd in directory proj (C:\CppLib\OpenCV-2.4.2_64bit\build\x64\vc10\proj\)
- Extract Irrlicht (C:\CppLib\irrlicht-1.7.3)
- Complie Irrlicht 64bit (32bit version is compiled and works out of the box)
- Open C:\CppLib\irrlicht-1.7.3\source\Irrlicht\Irrlicht9.0.sln in Visual Studio and convert the project
- Open Configuration Manager (project properties -> Configuration manager) -> New platform -> x64 -> Copy from Win32
- In Project properties select All configurations and set C/C++ - Additional include directories - C:\CppLib\DirectXSDK-June2010\Include (directX SDK install dir\include)
- In Project properties select Release - Linker - General - Output File - ..\..\bin\Win64-visualstudio\Irrlicht.dll
- In Project properties select Release - Linker - Advanced - Import library - ..\..\lib\Win64-visualstudio\Irrlicht.lib
- In Project properties select Release - C/C++ - Preprocessor - Preprocessor definitions - WIN64;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
- Open IrrCompileconfig.h and comment out the line #define _IRR_COMPILE_WITH_DIRECT3D_8_ (line 120)
- Try to compile, if it does not work and the error is Error LNK1112: module machine type x64 conflicts with target machine type X86 d:\SDK\irrlicht_svn\work\debug64\CDefaultSceneNodeAnimatorFactory.obj then close the solution in Visual Studio and manually delete item <AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions> contained in <ItemDefinitionGroup Condition=$(Configuration)|$(Platform)==Release|x64> in file Irrlicht9.0.vcxproj (line 465)
- Compile and verify that both 32bit and 64bit DLLs are present and are different
- Extract Boost (C:\CppLib\boost-1.50.0), make sure that subdirectories are 'boost', 'libs', 'tools', ...
- Compile Boost
- Run buildBoost.cmd in directory (C:\CppLib\boost-1.50.0)
- Make yourself a coffee
- Make a second one
- Add/Set the following (user) environment variables:
- IRRLICHT = C:\CppLib\irrlicht-1.7.3
- OPENCV = C:\CppLib\OpenCV-2.4.2 (note the missing _64bit suffix!)
- BOOST = C:\CppLib\boost-1.50.0
- TBB30_INSTALL_DIR = C:\CppLib\tbb40_20120613oss
- ARHELL_HOME = C:\ARHell\trunk (ie. ARHell root directory which contains subdirectories 'etc', 'bin', 'markers', ...)
- Add the following to environment variable %PATH%:
- Path to OpenCV DLLs: %OPENCV%_64bit\build\x86\vc10\bin\;%OPENCV%_64bit\build\x64\vc10\bin\;
- Path to TBB DLLs: %TBB30_INSTALL_DIR%\bin\intel64\vc10\;%TBB30_INSTALL_DIR%\bin\ia32\vc10\;
- Path to Irrlicht DLLs: %IRRLICHT%\bin\Win32-VisualStudio\;%IRRLICHT%\bin\Win64-VisualStudio\;
- Path to QT DLLS: C:\CppLib\Qt\Desktop\Qt\4.8.1\msvc2010\bin;
- Compile and run ARHell
Troubleshooting¶
Problem¶
When running the application, the following error occurs: Entry point not found in XXX.dll (Vstupní bod nebyl nalezen v XXX.dll)
Solution¶
There are more DLLs of the given name in the system and accessible in search path. The solution is to remove outdated DLLs from system or reorder %PATH% entries so that the first path entry points to the latest version.
Problem¶
Build fails (namespace XXX not defined or linker error)
Solution¶
Verify that the libraries are installed in correct directories. The correct directory structure is:
- boost-1.50.0
- boost
- lib
- lib_64bit
- ...
- DirectXSDK-June2010
- Include
- Lib
- Utilities
- ...
- irrlicht-1.7.3
- bin
- include
- lib
- ...
- OpenCV-2.4.2_64bit
- build
- include
- modules
- ...
- Qt
- Desktop
- QtCreator
- ...
- tbb40_20120613oss
- bin
- include
- lib
- ...
Restart Visual Studio to make sure that changes in environment variables are in effect. Check that Paths in Visual studio are correct.
Problem¶
CMake (when trying to build OpenCV) fails with the following error:
(TRY_COMPILE): Cannot copy output executable "" to destination specified by COPY_FILE CMake fails to deterimine the bitness of target platform. Please check your CMake and compiler installation. If you are crosscompiling then ensure that your CMake toolchain file correctly sets the compiler details
Solution¶
CMake must be run with administrator priviledges (shortcut properties - shortcut - advanced - run as administrator). The real cause is that CMake tries to execute devenv.com file which is a command line wrapper for Visual Studio 2010 which does not support auto-elevation.