Project

General

Profile

<h1>Visual studio project</h1>

<h2 id="Instructions">Instructions</h2>

<p>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.</p>

<ol>
<li>Download&nbsp;<a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/&quot;&gt;&amp;nbsp;OpenCV library installer</a>&nbsp;(<a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.2/OpenCV-2.4.2.exe/download&quot;&gt;&amp;nbsp;Latest working version</a>) (<em>OpenCV-2.4.2.exe</em>)</li>
<li>Download&nbsp;<a href="http://www.cmake.org/cmake/resources/software.html&quot;&gt;&amp;nbsp;CMake Win32 Installer</a>&nbsp;(<a href="http://www.cmake.org/files/v2.8/cmake-2.8.8-win32-x86.exe&quot;&gt;&amp;nbsp;Latest working version</a>) (<em>cmake-2.8.8-win32-x86.exe</em>)</li>
<li>Download&nbsp;<a href="http://threadingbuildingblocks.org/file.php?fid=77&quot;&gt;&amp;nbsp;TBB library</a>&nbsp;(<em>tbb40_20120613oss_win.zip</em>)</li>
<li>Download&nbsp;<a href="http://qt.nokia.com/downloads&quot;&gt;&amp;nbsp;QT library</a>&nbsp;(<em>QtSdk-online-win-x86-v1_2_1.exe</em>)</li>
<li>Download&nbsp;<a href="http://irrlicht.sourceforge.net/downloads/&quot;&gt;&amp;nbsp;Irrlicht library</a>&nbsp;(<em>irrlicht-1.7.3.zip</em>)</li>
<li>Download&nbsp;<a href="http://www.microsoft.com/en-us/download/details.aspx?id=6812&quot;&gt;&amp;nbsp;Directx SDK</a>&nbsp;(<em>DXSDK_Jun10.exe</em>)</li>
<li>Download&nbsp;<a href="http://sourceforge.net/projects/boost/files/boost/1.50.0/&quot;&gt;&amp;nbsp;Boost library</a>&nbsp;(<em>boost_1_50_0.7z</em>)</li>
</ol>

<hr />
<ol>
<li>Install CMake</li>
<li>Install QT SDK (Only the component&nbsp;<em>Qt 4.8.1 MSVC 2010</em>&nbsp;is necessary) (<em>C:\CppLib\Qt\</em>)</li>
<li>Install DirectX SDK (make sure to check&nbsp;<em>Headers and libs</em>,&nbsp;<em>Symbol Files</em>,&nbsp;<em>Runtime Support</em>,&nbsp;<em>Utilities</em>) (<em>C:\CppLib\DirectXSDK-June2010</em>)</li>
<li>Extract TBB (<em>C:\CppLib\tbb40_20120613oss</em>)</li>
<li>Build OpenCV (it is advisable to recompile both 32bit and 64bit binaries since the shipped version often causes random crashes)
<ol>
<li>Install OpenCV to C:\CppLib\OpenCV-2.4.2_64bit - directory needs to end with&nbsp;<em>_64bit</em>&nbsp;! (because of VRUT settings)</li>
<li>Move contents of&nbsp;<em>opencv</em>&nbsp;directory one directory up (so that it exists&nbsp;<em>C:\CppLib\OpenCV-2.4.2_64bit\build</em>)</li>
<li>Run CMake (cmake-gui)</li>
<li>Set&nbsp;<em>Where is the source code</em>&nbsp;to C:/CppLib/OpenCV-2.4.2_64bit/ (OpenCV installation directory)</li>
<li>Set&nbsp;<em>Where to build the binaries</em>&nbsp;to C:/CppLib/OpenCV-2.4.2_64bit/build/&#39;&#39;&#39;x86&#39;&#39;&#39;/vc10/proj</li>
<li><em>Configure</em></li>
<li>Set&nbsp;<em>Specify generator for this project</em>&nbsp;= Visual Studio 10 (ie. Visual Studio 2010) and&nbsp;<em>Use default native compilers</em></li>
<li>Check&nbsp;<em>WITH_QT</em>&nbsp;and&nbsp;<em>WITH_TBB</em>&nbsp;uncheck&nbsp;<em>BUILD_opencv_python</em>&nbsp;and&nbsp;<em>WITH_CUDA</em></li>
<li><em>Configure</em></li>
<li>Set&nbsp;<em>QT_QMAKE_EXECUTABLE</em>&nbsp;to&nbsp;<em>C:/CppLib/Qt/Desktop/Qt/4.8.1/msvc2010/bin/qmake.exe</em></li>
<li>Set&nbsp;<em>TBB_INCLUDE_DIRS</em>&nbsp;to&nbsp;<em>C:/CppLib/tbb40_20120613oss/include</em></li>
<li><em>Configure</em>,&nbsp;<em>Configure</em></li>
<li>If nothing is red, then&nbsp;<em>Generate</em></li>
<li>Open C:\CppLib\OpenCV-2.4.2_64bit\build\<strong>x86</strong>\vc10\proj\OpenCV.sln in Visual Studio</li>
<li>Select configuration&nbsp;<em>Debug</em>&nbsp;and project&nbsp;<em>ALL_BUILD</em>&nbsp;and Build</li>
<li>Select configuration&nbsp;<em>Release</em>&nbsp;and&nbsp;<em>ALL_BUILD</em>&nbsp;and Build</li>
<li>Run&nbsp;<a href="http://aistorm.mendelu.cz/arhelltrac/wiki/copy_open_cv_cmd&quot;&gt;copyOpenCV.cmd&lt;/a&gt;&amp;nbsp;in directory&nbsp;<em>proj</em>&nbsp;(C:\CppLib\OpenCV-2.4.2_64bit\build\<strong>x86</strong>\vc10\proj\)</li>
<li>Back to CMake and set&nbsp;<em>Where to build the binaries</em>&nbsp;to&nbsp;<em>C:/CppLib/OpenCV-2.4.2_64bit/build/&#39;&#39;&#39;x64&#39;&#39;&#39;/vc10/proj</em></li>
<li><em>Configure</em></li>
<li><em>Specify generator for this project</em>&nbsp;=&nbsp;<em>Visual Studio 10 Win64</em>&nbsp;(ie. Visual studio 2010) and&nbsp;<em>Use default native compilers</em></li>
<li>Check&nbsp;<em>WITH_TBB</em>&nbsp;uncheck&nbsp;<em>WITH_CUDA</em>&nbsp;and&nbsp;<em>WITH_QT</em>&nbsp;(Qt does not work for 64bit)</li>
<li><em>Configure</em></li>
<li>Set&nbsp;<em>TBB_INCLUDE_DIRS</em>&nbsp;to&nbsp;<em>C:/CppLib/tbb40_20120613oss/include</em>&nbsp;(same as for 32bit version)</li>
<li><em>Configure</em>,&nbsp;<em>Configure</em></li>
<li>If nothing is red, then&nbsp;<em>Generate</em></li>
<li>Open C:\CppLib\OpenCV-2.4.2_64bit\build\<strong>x64</strong>\vc10\proj\OpenCV.sln in Visual studi</li>
<li>Select configuration&nbsp;<em>Debug</em>&nbsp;and project&nbsp;<em>ALL_BUILD</em>&nbsp;and build</li>
<li>Select configuration&nbsp;<em>Release</em>&nbsp;and project&nbsp;<em>ALL_BUILD</em>&nbsp;and build</li>
<li>Run&nbsp;<a href="http://aistorm.mendelu.cz/arhelltrac/wiki/copy_open_cv_cmd&quot;&gt;copyOpenCV.cmd&lt;/a&gt;&amp;nbsp;in directory&nbsp;<em>proj</em>&nbsp;(C:\CppLib\OpenCV-2.4.2_64bit\build\<strong>x64</strong>\vc10\proj\)</li>
</ol>
</li>
<li>Extract Irrlicht (C:\CppLib\irrlicht-1.7.3)</li>
<li>Complie Irrlicht 64bit (32bit version is compiled and works out of the box)
<ol>
<li>Open C:\CppLib\irrlicht-1.7.3\source\Irrlicht\Irrlicht9.0.sln in Visual Studio and convert the project</li>
<li>Open Configuration Manager (project properties -&gt;&nbsp;<em>Configuration manager</em>) -&gt;&nbsp;<em>New platform</em>&nbsp;-&gt;&nbsp;<em>x64</em>&nbsp;-&gt; Copy from&nbsp;<em>Win32</em></li>
<li>In&nbsp;<em>Project properties</em>&nbsp;select&nbsp;<em>All configurations</em>&nbsp;and set&nbsp;<em>C/C++</em>&nbsp;-&nbsp;<em>Additional include directories</em>&nbsp;-&nbsp;<em>C:\CppLib\DirectXSDK-June2010\Include</em>&nbsp;(directX SDK install dir\include)</li>
<li>In&nbsp;<em>Project properties</em>&nbsp;select&nbsp;<em>Release</em>&nbsp;-&nbsp;<em>Linker</em>&nbsp;-&nbsp;<em>General</em>&nbsp;-&nbsp;<em>Output File</em>&nbsp;-&nbsp;<em>..\..\bin\Win<strong>64</strong>-visualstudio\Irrlicht.dll</em></li>
<li>In&nbsp;<em>Project properties</em>&nbsp;select&nbsp;<em>Release</em>&nbsp;-&nbsp;<em>Linker</em>&nbsp;-&nbsp;<em>Advanced</em>&nbsp;-&nbsp;<em>Import library</em>&nbsp;-&nbsp;<em>..\..\lib\Win64-visualstudio\Irrlicht.lib</em></li>
<li>In&nbsp;<em>Project properties</em>&nbsp;select&nbsp;<em>Release</em>&nbsp;-&nbsp;<em>C/C++</em>&nbsp;-&nbsp;<em>Preprocessor</em>&nbsp;-&nbsp;<em>Preprocessor definitions</em>&nbsp;-&nbsp;<em>WIN<strong>64</strong>;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</em></li>
<li>Open&nbsp;<em>IrrCompileconfig.h</em>&nbsp;and comment out the line&nbsp;<em>#define _IRR_COMPILE_WITH_DIRECT3D_8_</em>&nbsp;(line 120)</li>
<li>Try to compile, if it does not work and the error is&nbsp;<em>Error LNK1112: module machine type x64 conflicts with target machine type X86 d:\SDK\irrlicht_svn\work\debug64\CDefaultSceneNodeAnimatorFactory.obj</em>&nbsp;then close the solution in Visual Studio and manually delete item&nbsp;<em>&lt;AdditionalOptions&gt;/MACHINE:I386 %(AdditionalOptions)&lt;/AdditionalOptions&gt;</em>&nbsp;contained in&nbsp;<em>&lt;ItemDefinitionGroup Condition=$(Configuration)|$(Platform)==Release|x64&gt;</em>&nbsp;in file&nbsp;<em>Irrlicht9.0.vcxproj</em>&nbsp;(line 465)</li>
<li>Compile and verify that both 32bit and 64bit DLLs are present and are different</li>
</ol>
</li>
<li>Extract Boost (C:\CppLib\boost-1.50.0), make sure that subdirectories are &#39;boost&#39;, &#39;libs&#39;, &#39;tools&#39;, ...</li>
<li>Compile Boost
<ol>
<li>Run&nbsp;<a href="http://aistorm.mendelu.cz/arhelltrac/wiki/build_boost_cmd&quot;&gt;buildBoost.cmd&lt;/a&gt;&amp;nbsp;in directory (C:\CppLib\boost-1.50.0)</li>
<li>Make yourself a coffee</li>
<li>Make a second one</li>
</ol>
</li>
<li>Add/Set the following (user) environment variables:
<ol>
<li><em>IRRLICHT</em>&nbsp;=&nbsp;<em>C:\CppLib\irrlicht-1.7.3</em></li>
<li><em>OPENCV</em>&nbsp;=&nbsp;<em>C:\CppLib\OpenCV-2.4.2</em>&nbsp;(note the missing&nbsp;<strong>_64bit</strong>&nbsp;suffix!)</li>
<li><em>BOOST</em>&nbsp;=&nbsp;<em>C:\CppLib\boost-1.50.0</em></li>
<li><em>TBB30_INSTALL_DIR</em>&nbsp;=&nbsp;<em>C:\CppLib\tbb40_20120613oss</em></li>
<li><em>ARHELL_HOME</em>&nbsp;=&nbsp;<em>C:\ARHell\trunk</em>&nbsp;(ie. ARHell root directory which contains subdirectories &#39;etc&#39;, &#39;bin&#39;, &#39;markers&#39;, ...)</li>
</ol>
</li>
<li>Add the following to environment variable&nbsp;<em>%PATH%</em>:
<ol>
<li>Path to OpenCV DLLs:&nbsp;<em>%OPENCV%_64bit\build\x86\vc10\bin\;%OPENCV%_64bit\build\x64\vc10\bin\;</em></li>
<li>Path to TBB DLLs:&nbsp;<em>%TBB30_INSTALL_DIR%\bin\intel64\vc10\;%TBB30_INSTALL_DIR%\bin\ia32\vc10\;</em></li>
<li>Path to Irrlicht DLLs:&nbsp;<em>%IRRLICHT%\bin\Win32-VisualStudio\;%IRRLICHT%\bin\Win64-VisualStudio\;</em></li>
<li>Path to QT DLLS:&nbsp;<em>C:\CppLib\Qt\Desktop\Qt\4.8.1\msvc2010\bin;</em></li>
</ol>
</li>
<li>Compile and run ARHell</li>
</ol>

<h2 id="Troubleshooting">Troubleshooting</h2>

<h3 id="Problem">Problem</h3>

<p>When&nbsp;<strong>running</strong>&nbsp;the application, the following error occurs:&nbsp;<em>Entry point not found in XXX.dll</em>&nbsp;(<em>Vstupn&iacute; bod nebyl nalezen v XXX.dll</em>)</p>

<h3 id="Solution">Solution</h3>

<p>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.</p>

<h3 id="Problem1">Problem</h3>

<p>Build fails (<em>namespace XXX not defined</em>&nbsp;or&nbsp;<em>linker error</em>)</p>

<h3 id="Solution1">Solution</h3>

<p>Verify that the libraries are installed in correct directories. The correct directory structure is:</p>

<ul>
<li>boost-1.50.0
<ul>
<li>boost</li>
<li>lib</li>
<li>lib_64bit</li>
<li>...</li>
</ul>
</li>
<li>DirectXSDK-June2010
<ul>
<li>Include</li>
<li>Lib</li>
<li>Utilities</li>
<li>...</li>
</ul>
</li>
<li>irrlicht-1.7.3
<ul>
<li>bin</li>
<li>include</li>
<li>lib</li>
<li>...</li>
</ul>
</li>
<li>OpenCV-2.4.2_64bit
<ul>
<li>build</li>
<li>include</li>
<li>modules</li>
<li>...</li>
</ul>
</li>
<li>Qt
<ul>
<li>Desktop</li>
<li>QtCreator</li>
<li>...</li>
</ul>
</li>
<li>tbb40_20120613oss
<ul>
<li>bin</li>
<li>include</li>
<li>lib</li>
<li>...</li>
</ul>
</li>
</ul>

<p>Restart Visual Studio to make sure that changes in environment variables are in effect. Check that&nbsp;<a href="http://aistorm.mendelu.cz/arhelltrac/wiki/%3AVSPaths&quot;&gt;Paths in Visual studio</a>&nbsp;are correct.</p>

<h3 id="Problem2">Problem</h3>

<p>CMake (when trying to build OpenCV) fails with the following error:</p>

<p><em>(TRY_COMPILE): Cannot copy output executable &quot;&quot; to destination specified by COPY_FILE</em>&nbsp;<em>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</em></p>

<h3 id="Solution2">Solution</h3>

<p>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.</p>