Project

General

Profile

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.

  1. Download  OpenCV library installer ( Latest working version) (OpenCV-2.4.2.exe)
  2. Download  CMake Win32 Installer ( Latest working version) (cmake-2.8.8-win32-x86.exe)
  3. Download  TBB library (tbb40_20120613oss_win.zip)
  4. Download  QT library (QtSdk-online-win-x86-v1_2_1.exe)
  5. Download  Irrlicht library (irrlicht-1.7.3.zip)
  6. Download  Directx SDK (DXSDK_Jun10.exe)
  7. Download  Boost library (boost_1_50_0.7z)

  1. Install CMake
  2. Install QT SDK (Only the component Qt 4.8.1 MSVC 2010 is necessary) (C:\CppLib\Qt\)
  3. Install DirectX SDK (make sure to check Headers and libsSymbol FilesRuntime SupportUtilities) (C:\CppLib\DirectXSDK-June2010)
  4. Extract TBB (C:\CppLib\tbb40_20120613oss)
  5. Build OpenCV (it is advisable to recompile both 32bit and 64bit binaries since the shipped version often causes random crashes)
    1. Install OpenCV to C:\CppLib\OpenCV-2.4.2_64bit - directory needs to end with _64bit ! (because of VRUT settings)
    2. Move contents of opencv directory one directory up (so that it exists C:\CppLib\OpenCV-2.4.2_64bit\build)
    3. Run CMake (cmake-gui)
    4. Set Where is the source code to C:/CppLib/OpenCV-2.4.2_64bit/ (OpenCV installation directory)
    5. Set Where to build the binaries to C:/CppLib/OpenCV-2.4.2_64bit/build/'''x86'''/vc10/proj
    6. Configure
    7. Set Specify generator for this project = Visual Studio 10 (ie. Visual Studio 2010) and Use default native compilers
    8. Check WITH_QT and WITH_TBB uncheck BUILD_opencv_python and WITH_CUDA
    9. Configure
    10. Set QT_QMAKE_EXECUTABLE to C:/CppLib/Qt/Desktop/Qt/4.8.1/msvc2010/bin/qmake.exe
    11. Set TBB_INCLUDE_DIRS to C:/CppLib/tbb40_20120613oss/include
    12. ConfigureConfigure
    13. If nothing is red, then Generate
    14. Open C:\CppLib\OpenCV-2.4.2_64bit\build\x86\vc10\proj\OpenCV.sln in Visual Studio
    15. Select configuration Debug and project ALL_BUILD and Build
    16. Select configuration Release and ALL_BUILD and Build
    17. Run copyOpenCV.cmd in directory proj (C:\CppLib\OpenCV-2.4.2_64bit\build\x86\vc10\proj\)
    18. Back to CMake and set Where to build the binaries to C:/CppLib/OpenCV-2.4.2_64bit/build/'''x64'''/vc10/proj
    19. Configure
    20. Specify generator for this project = Visual Studio 10 Win64 (ie. Visual studio 2010) and Use default native compilers
    21. Check WITH_TBB uncheck WITH_CUDA and WITH_QT (Qt does not work for 64bit)
    22. Configure
    23. Set TBB_INCLUDE_DIRS to C:/CppLib/tbb40_20120613oss/include (same as for 32bit version)
    24. ConfigureConfigure
    25. If nothing is red, then Generate
    26. Open C:\CppLib\OpenCV-2.4.2_64bit\build\x64\vc10\proj\OpenCV.sln in Visual studi
    27. Select configuration Debug and project ALL_BUILD and build
    28. Select configuration Release and project ALL_BUILD and build
    29. Run copyOpenCV.cmd in directory proj (C:\CppLib\OpenCV-2.4.2_64bit\build\x64\vc10\proj\)
  6. Extract Irrlicht (C:\CppLib\irrlicht-1.7.3)
  7. Complie Irrlicht 64bit (32bit version is compiled and works out of the box)
    1. Open C:\CppLib\irrlicht-1.7.3\source\Irrlicht\Irrlicht9.0.sln in Visual Studio and convert the project
    2. Open Configuration Manager (project properties -> Configuration manager) -> New platform -> x64 -> Copy from Win32
    3. In Project properties select All configurations and set C/C++ - Additional include directories - C:\CppLib\DirectXSDK-June2010\Include (directX SDK install dir\include)
    4. In Project properties select Release - Linker - General - Output File - ..\..\bin\Win64-visualstudio\Irrlicht.dll
    5. In Project properties select Release - Linker - Advanced - Import library - ..\..\lib\Win64-visualstudio\Irrlicht.lib
    6. In Project properties select Release - C/C++ - Preprocessor - Preprocessor definitions - WIN64;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
    7. Open IrrCompileconfig.h and comment out the line #define _IRR_COMPILE_WITH_DIRECT3D_8_ (line 120)
    8. 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)
    9. Compile and verify that both 32bit and 64bit DLLs are present and are different
  8. Extract Boost (C:\CppLib\boost-1.50.0), make sure that subdirectories are 'boost', 'libs', 'tools', ...
  9. Compile Boost
    1. Run buildBoost.cmd in directory (C:\CppLib\boost-1.50.0)
    2. Make yourself a coffee
    3. Make a second one
  10. Add/Set the following (user) environment variables:
    1. IRRLICHT = C:\CppLib\irrlicht-1.7.3
    2. OPENCV = C:\CppLib\OpenCV-2.4.2 (note the missing _64bit suffix!)
    3. BOOST = C:\CppLib\boost-1.50.0
    4. TBB30_INSTALL_DIR = C:\CppLib\tbb40_20120613oss
    5. ARHELL_HOME = C:\ARHell\trunk (ie. ARHell root directory which contains subdirectories 'etc', 'bin', 'markers', ...)
  11. Add the following to environment variable %PATH%:
    1. Path to OpenCV DLLs: %OPENCV%_64bit\build\x86\vc10\bin\;%OPENCV%_64bit\build\x64\vc10\bin\;
    2. Path to TBB DLLs: %TBB30_INSTALL_DIR%\bin\intel64\vc10\;%TBB30_INSTALL_DIR%\bin\ia32\vc10\;
    3. Path to Irrlicht DLLs: %IRRLICHT%\bin\Win32-VisualStudio\;%IRRLICHT%\bin\Win64-VisualStudio\;
    4. Path to QT DLLS: C:\CppLib\Qt\Desktop\Qt\4.8.1\msvc2010\bin;
  12. 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.