OpenCV UWP build fails

匆匆过客 提交于 2019-12-12 04:45:50

问题


I cloned the official github repo of OpenCV and used CMake to generate the VS Solution.

 cmake -G "Visual Studio 14 2015" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" .

As you can see, I want to build OpenCV for UWP 32-Bit. When building in VS 2015 the opencv_core module fails with:

Error   C2664   'BOOL CreateDirectoryA(LPCSTR,LPSECURITY_ATTRIBUTES)': cannot convert argument 1 from 'wchar_t [260]' to 'LPCSTR'
Error   C2039   'CreateFileA': is not a member of '`global namespace''  
Error   C3861   'CreateFileA': identifier not found
Error   C2664   'DWORD GetTempPathW(DWORD,LPWSTR)': cannot convert argument 2 from 'char [261]' to 'LPWSTR'

All these error are in the opencv_core in the file "filesystem.cpp. Now, I already successfully build it a few weeks ago, before I had to reformat my pc. Now it just won't build and I don't know how to fix these. Could these problems be related to the Windows 10 SDK?


回答1:


Looks like you are mixing UNICODE and non-UNICODE builds. Make sure they're consistent and that you use the correct type of strings (use the TEXT() macro if you like).

To verify, right-click the project in VS and choose Properties and then expand C/C++ -> Preprocessor and check the Preprocessor definitions. Click the down-arrow next to the value and click <edit> and then verify the both UNICODE and _UNICODE are defined. If not, add them. You need to repeat this for each configuration (you can try and select "all" but that might mess things up if you have conflicting options).

For the last error, change the declaration from char to wchar_t to compile.



来源:https://stackoverflow.com/questions/47481503/opencv-uwp-build-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!