microsoft / opencv

Open Source Computer Vision Library
opencv.org
Apache License 2.0
144 stars 92 forks source link

CMake generated WindowsStore 8.0 ARM core module missing ole32.lib #12

Closed stammen closed 9 years ago

stammen commented 9 years ago

How to reproduce:

setup_winrt.bat ws 8.0 arm build OpenCV.sln in bin/WS/8.0/ARM

core module generates the following error because linker input is missing ole32.lib.

1>------ Build started: Project: opencv_core, Configuration: Debug ARM ------ 1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification 1> Creating library D:/GitHub/opencv/bin/WS/8.0/arm/lib/Debug/opencv_core300d.lib and object D:/GitHub/opencv/bin/WS/8.0/arm/lib/Debug/opencv_core300d.exp 1>system.obj : error LNK2019: unresolved external symbol __imp_CoCreateGuid referenced in function __unwind$4 1>D:\GitHub\opencv\bin\WS\8.0\arm\bin\Debug\opencv_core300d.dll : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

mkostin commented 9 years ago

On it. Preliminary investigation indicates that this might be a cmake platfrom configuration issue (lines 171,172):

 165 elseif(WINDOWS_PHONE OR WINDOWS_STORE)
 166   set(_PLATFORM_DEFINES "/DWIN32")
 167   set(_FLAGS_C " /DUNICODE /D_UNICODE")
 168   set(_FLAGS_CXX " /DUNICODE /D_UNICODE /GR /EHsc")
 169   if(WINDOWS_PHONE)
 170     set(CMAKE_C_STANDARD_LIBRARIES_INIT "WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib")
 171   elseif(MSVC_C_ARCHITECTURE_ID STREQUAL ARM OR MSVC_CXX_ARCHITECTURE_ID STREQUAL ARM)
 172     set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
 173   else()
 174     set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib")
 175   endif()
 176 else()

Configuration can be found locally at <cmake-installation-dir>\share\cmake-3.1\Modules\Platform\Windows-MSVC.cmake

stammen commented 9 years ago

You should probably check with Gilles.

Thanks,

Dale


From: Max Kostin notifications@github.com Sent: Wednesday, January 21, 2015 6:04 AM To: MSOpenTech/opencv Cc: Dale Stammen (MS OPEN TECH) Subject: Re: [opencv] CMake generated WindowsStore 8.0 ARM core module missing ole32.lib (#12)

On it. Preliminary investigation indicates that this might be a cmake platfrom configurationhttp://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Platform/Windows-MSVC.cmake;hb=v3.1.0#l179 issue:

179 if(MSVC_C_ARCHITECTURE_ID STREQUAL ARM OR MSVC_CXX_ARCHITECTURE_ID STREQUAL ARM) 180 set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib") 181 elseif(MSVC_VERSION GREATER 1310) 182 set(_RTC1 "/RTC1") 183 set(_FLAGS_CXX " /GR /EHsc") 184 set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib") 185 else() 186 set(_RTC1 "/GZ") 187 set(_FLAGS_CXX " /GR /GX") 188 set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib") 189 endif()

Reply to this email directly or view it on GitHubhttps://github.com/MSOpenTech/opencv/issues/12#issuecomment-70841842.

mkostin commented 9 years ago

Adding ole32.lib (line 172) in the Windows-MSVC.cmake configuration file shipped with cmake installations fixes the issue.

<path-to-cmake-installation-dir>\share\cmake-3.1\Modules\Platform\Windows-MSVC.cmake

- set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
+ set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib ole32.lib")

Regenerating OCV projects with

cmake 
  -G Visual Studio 12 2013 ARM 
  -DCMAKE_SYSTEM_NAME:String=WindowsStore 
  -DCMAKE_SYSTEM_VERSION:String=8.0 
  <path-to-cmake-src> 

or alternatively using wrapper script (ends up with the same command)

<path-to-cmake-src>/platfroms/winrt/setup_winrt.bat WS 8.0 ARM

makes it build successfully.

mkostin commented 9 years ago

CC Gilles @khouzam

stammen commented 9 years ago

I added the missing ole32.lib for WindowsStore 8.0 in modules/core/CMakeLists.txt.

khouzam commented 9 years ago

Thanks. I'll see to get it add to CMake

mkostin commented 9 years ago

referencing commit: 5f040ca91e013e2db1c65cae31d34c85cf446359