0

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 Answers1

0

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.

Peter Torr - MSFT
  • 11,824
  • 3
  • 18
  • 51
  • Thanks you for your answer. Is there a way to fix this without modifying OpenCV source code? If read about changing the character set in VS, unfortunately the option doesn't exist in VS 2015 anymore (or I can't find it) – noobprogrammer Nov 25 '17 at 11:53
  • It's hard to give precise advice because you don't list where the errors are coming from. I added some info though. – Peter Torr - MSFT Nov 27 '17 at 05:37