OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.79k stars 2.51k forks source link

[PATCH] Port to Windows UWP #1201

Open crule42 opened 5 years ago

crule42 commented 5 years ago

Expected behavior and actual behavior.

Be able to compile gdal using visual studio configured to create a UWP application (windows store app). There are several compile errors.

Operating system - Windows

GDAL version and provenance

master branch - REV: 1991ea2daa9d0cbd29cd04095309df497f95a95e

I've included a patch if anyone is interested in continuing with this. I don't believe this is for all of gdal and I have not tried running any of this. This is just to get it to the point of compiling. I was doing this as part of porting another package.

0001-Updates-to-compile-using-windows-UWP.zip

dotMorten commented 5 years ago

Also see the changes I made in these two PRs in our fork:

They're not a full UWP implementation, but just ensures the bits of GDAL we actually use are working on UWP (there's probably a lot more things to tweak in areas we aren't hitting).

I'd be more than happy to upstream these changes back into GDAL if the repo owners are willing to accept these partial UWP fixes (and hopefully we can chip away at more as we go).

Another thing to consider is to replace all CreateFile calls with CreateFile2 calls once Windows 7 End-of-life hits in January 2020, as this is the main change for UWP, and that API is available on Windows 8 and up for Win32 apps as well.

rouault commented 5 years ago

I'm happy with the principle of partial PRs if they are not too intrusive

rouault commented 2 years ago

@dotMorten is there still any interest in this ?

dotMorten commented 2 years ago

So the good news is since this was logged a LOT of apis have been white listed and if I'm not mistaken there's only one call left that isn't allowed to be used from within the sandbox.

dg0yt commented 2 years ago

Testing v3.5.2RC1 with uwp in vcpkg CI:

FAILED: port/CMakeFiles/cpl.dir/cpl_spawn.cpp.obj 
C:\PROGRA~1\MICROS~1\2022\ENTERP~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\cl.exe   /TP -DGDAL_CMAKE_BUILD -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_CURL -DHAVE_ICONV -DHAVE_LIBXML2 -DHAVE_LIBZ -DHAVE_LZMA -DHAVE_OPENSSL_CRYPTO -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_ZLIB -DHAVE_ZLIB_H -DHAVE_ZSTD -DINST_DATA=\"D:/packages/gdal_x64-uwp/debug/share/gdal\" -DNOMINMAX -DSYSCONFDIR=\"D:/packages/gdal_x64-uwp/debug/etc\" -DZIP_SUPPORT -DZLIB_DLL -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_WIN64 -ID:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port -ID:\buildtrees\gdal\x64-uwp-dbg\port -ID:\installed\x64-uwp\include\json-c -ID:\installed\x64-uwp\include -ID:\installed\x64-uwp\include\libxml2 /DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__ /nologo /Z7 /MP /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc  /utf-8  /D_DEBUG /Od /RTC1 /MDd  -MDd /EHsc /W4 /wd4127 /wd4251 /wd4275 /wd4786 /wd4100 /wd4245 /wd4206 /wd4351 /wd4611 /showIncludes /Foport\CMakeFiles\cpl.dir\cpl_spawn.cpp.obj /Fdport\CMakeFiles\cpl.dir\ /FS -c D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_spawn.cpp
cl : Command line warning D9025 : overriding '/W3' with '/W4'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_spawn.cpp(273): error C2065: 'HANDLE_FLAG_INHERIT': undeclared identifier
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_spawn.cpp(284): error C2065: 'HANDLE_FLAG_INHERIT': undeclared identifier
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_spawn.cpp(295): error C2065: 'HANDLE_FLAG_INHERIT': undeclared identifier
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_spawn.cpp(315): error C2065: 'STARTF_USESTDHANDLES': undeclared identifier
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_spawn.cpp(335): error C2664: 'BOOL CreateProcessW(LPCWSTR,LPWSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCWSTR,LPSTARTUPINFOW,LPPROCESS_INFORMATION)': cannot convert argument 2 from 'CHAR *' to 'LPWSTR'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_spawn.cpp(336): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\processthreadsapi.h(385): note: see declaration of 'CreateProcessW'

FAILED: port/CMakeFiles/cpl.dir/cpl_http.cpp.obj 
C:\PROGRA~1\MICROS~1\2022\ENTERP~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\cl.exe   /TP -DGDAL_CMAKE_BUILD -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_CURL -DHAVE_ICONV -DHAVE_LIBXML2 -DHAVE_LIBZ -DHAVE_LZMA -DHAVE_OPENSSL_CRYPTO -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_ZLIB -DHAVE_ZLIB_H -DHAVE_ZSTD -DINST_DATA=\"D:/packages/gdal_x64-uwp/debug/share/gdal\" -DNOMINMAX -DSYSCONFDIR=\"D:/packages/gdal_x64-uwp/debug/etc\" -DZIP_SUPPORT -DZLIB_DLL -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_WIN64 -ID:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port -ID:\buildtrees\gdal\x64-uwp-dbg\port -ID:\installed\x64-uwp\include\json-c -ID:\installed\x64-uwp\include -ID:\installed\x64-uwp\include\libxml2 /DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__ /nologo /Z7 /MP /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc  /utf-8  /D_DEBUG /Od /RTC1 /MDd  -MDd /EHsc /W4 /wd4127 /wd4251 /wd4275 /wd4786 /wd4100 /wd4245 /wd4206 /wd4351 /wd4611 /showIncludes /Foport\CMakeFiles\cpl.dir\cpl_http.cpp.obj /Fdport\CMakeFiles\cpl.dir\ /FS -c D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_http.cpp
cl : Command line warning D9025 : overriding '/W3' with '/W4'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_http.cpp(189): error C2664: 'HCERTSTORE CertOpenSystemStoreW(HCRYPTPROV_LEGACY,LPCWSTR)': cannot convert argument 2 from 'const char *' to 'LPCWSTR'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_http.cpp(190): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\wincrypt.h(16630): note: see declaration of 'CertOpenSystemStoreW'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_http.cpp(1805): error C3861: 'SearchPathA': identifier not found

FAILED: port/CMakeFiles/cpl.dir/cplgetsymbol.cpp.obj 
C:\PROGRA~1\MICROS~1\2022\ENTERP~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\cl.exe   /TP -DGDAL_CMAKE_BUILD -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_CURL -DHAVE_ICONV -DHAVE_LIBXML2 -DHAVE_LIBZ -DHAVE_LZMA -DHAVE_OPENSSL_CRYPTO -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_ZLIB -DHAVE_ZLIB_H -DHAVE_ZSTD -DINST_DATA=\"D:/packages/gdal_x64-uwp/debug/share/gdal\" -DNOMINMAX -DSYSCONFDIR=\"D:/packages/gdal_x64-uwp/debug/etc\" -DZIP_SUPPORT -DZLIB_DLL -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_WIN64 -ID:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port -ID:\buildtrees\gdal\x64-uwp-dbg\port -ID:\installed\x64-uwp\include\json-c -ID:\installed\x64-uwp\include -ID:\installed\x64-uwp\include\libxml2 /DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__ /nologo /Z7 /MP /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc  /utf-8  /D_DEBUG /Od /RTC1 /MDd  -MDd /EHsc /W4 /wd4127 /wd4251 /wd4275 /wd4786 /wd4100 /wd4245 /wd4206 /wd4351 /wd4611 /showIncludes /Foport\CMakeFiles\cpl.dir\cplgetsymbol.cpp.obj /Fdport\CMakeFiles\cpl.dir\ /FS -c D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cplgetsymbol.cpp
cl : Command line warning D9025 : overriding '/W3' with '/W4'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cplgetsymbol.cpp(151): error C2065: 'SEM_NOOPENFILEERRORBOX': undeclared identifier
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cplgetsymbol.cpp(151): error C2065: 'SEM_FAILCRITICALERRORS': undeclared identifier
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cplgetsymbol.cpp(167): error C2065: 'HINSTANCE_ERROR': undeclared identifier

FAILED: port/CMakeFiles/cpl.dir/cpl_multiproc.cpp.obj 
C:\PROGRA~1\MICROS~1\2022\ENTERP~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\cl.exe   /TP -DGDAL_CMAKE_BUILD -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_CURL -DHAVE_ICONV -DHAVE_LIBXML2 -DHAVE_LIBZ -DHAVE_LZMA -DHAVE_OPENSSL_CRYPTO -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_ZLIB -DHAVE_ZLIB_H -DHAVE_ZSTD -DINST_DATA=\"D:/packages/gdal_x64-uwp/debug/share/gdal\" -DNOMINMAX -DSYSCONFDIR=\"D:/packages/gdal_x64-uwp/debug/etc\" -DZIP_SUPPORT -DZLIB_DLL -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_WIN64 -ID:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port -ID:\buildtrees\gdal\x64-uwp-dbg\port -ID:\installed\x64-uwp\include\json-c -ID:\installed\x64-uwp\include -ID:\installed\x64-uwp\include\libxml2 /DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__ /nologo /Z7 /MP /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc  /utf-8  /D_DEBUG /Od /RTC1 /MDd  -MDd /EHsc /W4 /wd4127 /wd4251 /wd4275 /wd4786 /wd4100 /wd4245 /wd4206 /wd4351 /wd4611 /showIncludes /Foport\CMakeFiles\cpl.dir\cpl_multiproc.cpp.obj /Fdport\CMakeFiles\cpl.dir\ /FS -c D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_multiproc.cpp
cl : Command line warning D9025 : overriding '/W3' with '/W4'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_multiproc.cpp(1144): error C3861: 'CreateFileA': identifier not found
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_multiproc.cpp(1155): error C3861: 'CreateFileA': identifier not found

FAILED: port/CMakeFiles/cpl.dir/cpl_vsil_win32.cpp.obj 
C:\PROGRA~1\MICROS~1\2022\ENTERP~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\cl.exe   /TP -DGDAL_CMAKE_BUILD -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_CURL -DHAVE_ICONV -DHAVE_LIBXML2 -DHAVE_LIBZ -DHAVE_LZMA -DHAVE_OPENSSL_CRYPTO -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_ZLIB -DHAVE_ZLIB_H -DHAVE_ZSTD -DINST_DATA=\"D:/packages/gdal_x64-uwp/debug/share/gdal\" -DNOMINMAX -DSYSCONFDIR=\"D:/packages/gdal_x64-uwp/debug/etc\" -DZIP_SUPPORT -DZLIB_DLL -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_WIN64 -ID:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port -ID:\buildtrees\gdal\x64-uwp-dbg\port -ID:\installed\x64-uwp\include\json-c -ID:\installed\x64-uwp\include -ID:\installed\x64-uwp\include\libxml2 /DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__ /nologo /Z7 /MP /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc  /utf-8  /D_DEBUG /Od /RTC1 /MDd  -MDd /EHsc /W4 /wd4127 /wd4251 /wd4275 /wd4786 /wd4100 /wd4245 /wd4206 /wd4351 /wd4611 /showIncludes /Foport\CMakeFiles\cpl.dir\cpl_vsil_win32.cpp.obj /Fdport\CMakeFiles\cpl.dir\ /FS -c D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp
cl : Command line warning D9025 : overriding '/W3' with '/W4'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(446): error C2664: 'HMODULE GetModuleHandleW(LPCWSTR)': cannot convert argument 1 from 'const char [10]' to 'LPCWSTR'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(446): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\libloaderapi.h(244): note: see declaration of 'GetModuleHandleW'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(635): error C3861: 'CreateFileW': identifier not found
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(663): error C3861: 'CreateFileW': identifier not found
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(672): error C3861: 'CreateFile': identifier not found
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(983): error C2664: 'BOOL GetDiskFreeSpaceExW(LPCWSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER)': cannot convert argument 1 from 'const char *' to 'LPCWSTR'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(983): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\fileapi.h(422): note: see declaration of 'GetDiskFreeSpaceExW'
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(1010): error C2664: 'BOOL GetVolumeInformationW(LPCWSTR,LPWSTR,DWORD,LPDWORD,LPDWORD,LPDWORD,LPWSTR,DWORD)': cannot convert argument 1 from 'const _Elem *' to 'LPCWSTR'
        with
        [
            _Elem=char
        ]
D:\buildtrees\gdal\src\v3.5.2RC1-75e759b833.clean\port\cpl_vsil_win32.cpp(1010): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\fileapi.h(891): note: see declaration of 'GetVolumeInformationW'