I am trying to use the OpenCV library for some image processing inside my Windows 8 Store app using C++/CX. I am able to build the OpenCV library using Visual C++ 2012 but
I've managed to build a subset of OpenCV for ARM.
I started by getting the subset I was interested in building for Windows Store applications in x86. After pointing CMake at a source download of OpenCV, I used the Visual Studio 11 generator to configure an x86 project. I added a new build option within CMake called TARGET_METRO, and used this to further configure the other projects.
This allowed me to turn off several 3rd-party components I did not want to build, eg:
OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS AND NOT TARGET_METRO) )
I turned off WITH_VIDEOINPUT, BUILD_PERF_TESTS, and BUILD_TESTS in this fashion. I also added the definitions mentioned by Raman when TARGET_METRO was on:
if(TARGET_METRO)
add_definitions(-DWINAPI_FAMILY=WINAPI_FAMILY_APP)
add_definitions(-D_UNICODE)
endif()
I then proceeded to generate the x86 (Visual Studio 11) version of the project with CMake and started attempting to build the project. You will run into a number of issues, most of which relate to missing APIs in WinRT. Most of these are mechanical changes (for example, swapping out InitializeCriticalSection
for InitializeCriticalSectionEx
). I wrapped these changes under #if WINAPI_FAMILY == WINAPI_FAMILY_APP
so that it would not impact the non-TARGET_METRO build.
When it came time to build for ARM, what I did was launch CMake and use the Visual Studio 11 generator to generate a new project (under a directory named 'ARM') and then began manually editing the resulting project files.
The major changes you need to make are:
true
to the Globals propertygroupAdd the following at the project level (for each project you want to build for ARM):
false
Console
false
false
Remove "/machine:X86 " from Link: Additional Options (if it is in there)