compnerd/swift-win32

Build error: cannot find type 'WICPixelFormatGUID' in scope

armak opened this issue · 10 comments

armak commented

I'm trying to build the project with a clean installation of the latest Swift release from https://swift.org/download/, but the build encounters the following error:

$ ninja -C build SwiftWin32 UICatalog
ninja: Entering directory `build'
[1/3] Linking Swift shared library bin\SwiftCOM.dll
FAILED: bin/SwiftCOM.dll Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/COMBase.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Shell.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Extensions/COMTypes+Extensions.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Extensions/String+Extensions.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Extensions/WinSDK+Extensions.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Implementation/Human/IFileOperationProgressSink.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IBindCtx.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IEnumMoniker.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IEnumString.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IEnumUnknown.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IErrorLog.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IFileOperation.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IMalloc.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IMoniker.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IObjectWithPropertyKey.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IOperationsProgressDialog.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IPersist.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IPersistStream.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IPropertyBag2.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IPropertyChange.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IPropertyChangeArray.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IRunningObjectTable.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IShellItem.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IStream.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmap.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapClipper.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapCodecInfo.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapDecoder.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapDecoderInfo.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapEncoder.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapEncoderInfo.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapFlipRotator.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapFrameDecode.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapFrameEncode.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapLock.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapScaler.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICBitmapSource.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICColorContext.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICColorTransform.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICComponentInfo.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICFastMetadataEncoder.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICFormatConverter.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICImagingFactory.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICMetadataQueryReader.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICMetadataQueryWriter.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICPalette.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/Human/IWICStream.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/ITypeComp.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/ITypeInfo.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/ITypeLib.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Interfaces/IUnknown.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Support/Error.swift.obj Sources/CMakeFiles/SwiftCOM.dir/__/Packages/SwiftCOM/Sources/SwiftCOM/Support/RawTyped.swift.obj swift/SwiftCOM.swiftmodule lib/SwiftCOM.lib
cmd.exe /C "cd . && C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -output-file-map Sources\CMakeFiles\SwiftCOM.dir\Release\output-file-map.json -incremental -j 16 -emit-library -o bin\SwiftCOM.dll -module-name SwiftCOM -module-link-name SwiftCOM -emit-module -emit-module-path swift\SwiftCOM.swiftmodule -emit-dependencies -DSwiftCOM_EXPORTS -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -O -libc MD  @CMakeFiles\SwiftCOM.rsp    -Xlinker -implib:lib\SwiftCOM.lib  && cd ."
Active code page: 65001
../Packages/SwiftCOM/Sources/SwiftCOM/Extensions/WinSDK+Extensions.swift:18:56: error: cannot find type 'WICPixelFormatGUID' in scope
public typealias REFWICPixelFormatGUID = UnsafePointer<WICPixelFormatGUID>
                                                       ^~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

Output of swift -version is

compnerd.org Swift version 5.3.2 (swift-5.3.2-RELEASE)
Target: x86_64-unknown-windows-msvc

This is expected. If you are building with 5.3, you will need to roll back to a much older state. The current development state requires that you use snapshots, not the stable release.

BTW, this is documented here: https://github.com/compnerd/swift-win32#build-requirements. Is there something which would make this clearer for someone getting started?

armak commented

Thank you for the reply. I did see the requirements. The Swift version (5.3.2) I'm using is dated 14th of December on the download page, so I assumed "11/08" from the requirements would mean any version from 8th of November of newer, or am I misinterpreting it? If these requirements are for the current master of this repository then I think I should be covered?

Right, the 5.3.2 release was recent, but it is a dot release for fixes for 5.3. The need is for development snapshots, which are from the main branch, not the release branches. I suppose that something from the 5.4 release branch could work as well, though, that can break as new things get added. Would you have any suggestions on how to make this clearer in the documentation?

armak commented

Ah, fair enough. Maybe specifying "development snapshot" would be a bit more explicit? Possibly would be good to underline that the official release versions aren't applicable, or even maintain a branch that is compatible with the latest stable version. That's my two cents anyway.

I'll look if I can make the build succeed with an older version, thanks.

The maintenance with the latest stable version would certainly be reasonable. The problem is that the Windows port has been moving at a pace that makes it nearly untenable. I suppose that part of the problem is that I've simply opted to fix issues in the Swift toolchain rather than workaround the problems. I'd be entirely open to merging patches to maintain compatibility with the stable releases.

Added a note about the release versions to the main readme.

Hello @armak . I had the same problem as you. I suspect that the problem is caused by the winsdk modulemap included the swift setup which does not export the WICPixelFormatGUID. Can you try again and follow the instructions on my video ?

https://www.youtube.com/watch?v=Vp_wULne7b4

I hope this fixes your prolem 👍

Yes, the project requires development snapshots. Unfortunately, the currently posted snapshot is missing a required change. The issue has been fixed for a week or so, but the swift.org page doesnt have the latest snapshots.

1/12/2021
1/14/2021
1/15/2021
1/16/2021

Any one of those should include the fix for the ActiveX module missing. It seems that some of the changes that I had done to enable the DirectX caused a regression.

I'm going to go ahead and close this for now. If the problem persists, please feel free to re-open.