Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile example #711

Closed
Higher08 opened this issue Jun 13, 2022 · 13 comments
Closed

Can't compile example #711

Higher08 opened this issue Jun 13, 2022 · 13 comments

Comments

@Higher08
Copy link

Higher08 commented Jun 13, 2022

I have done and installed everything as in getting started on swift.org.
But when I try to execute make command (copied from Readme) I have this error

The C compiler

    "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx86/x86/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/Dmytro/Downloads/swift-win32-main/swift-win32-main/Examples/UICatalog/build/CMakeFiles/CMakeTmp

What I'm doing wrong?

@Higher08 Higher08 changed the title Can, Can't compile example Jun 13, 2022
@Higher08
Copy link
Author

Higher08 commented Jun 13, 2022

With swift build --product UICatalog I have invalidManifestError (could not build C module "SwiftOverlayShims"
Also, when I run x86 Native Tools Command Prompt, UniversalCRTSdkDir is not defined. I don't think it's correct

@compnerd
Copy link
Owner

You won't be able to build with the x86 toolset, this project currently is not 32-bit clean. Furthermore, once #699 is merged, the project exposes limitations in the Swift toolchain wrt calling convention handling that will prevent the correct argument handling resulting in a failure from within the callbacks from Win32 to handle the events.

The errors sound like you didn't follow the installation instructions correctly and the deployment of the modulemaps failed which results in being unable to access the system headers. I would say that you should uninstall Swift, reinstall Visual Studio (ensuring that you add the necessary C/C++ components or just install the C/C++ workload support) and then re-install the Swift toolchain.

@Higher08
Copy link
Author

Higher08 commented Jun 13, 2022

I don't build with the x86 toolset, I'm trying to execute these commands from https://www.swift.org/getting-started/ (support files).

The following will modify your Visual Studio Installation, and as such will require to be run from an (elevated) “Administrator” x86 Native Tools for VS2019 Command Prompt.

I tried reinstalling VS, but this doesn't help. I'm using VS2022 with the latest MSVC, it's not a problem?
P.S in vs installer I selected CMake support and msvc only

@compnerd
Copy link
Owner

P.S in vs installer I selected CMake support and msvc only

I think that this is the problem. You aren't installing all the necessary pieces of Visual Studio. The necessary components are listed on the getting started page. The easiest thing to do is to just install the C++ workload. Once that is installed properly, reinstall Swift.

@Higher08
Copy link
Author

Higher08 commented Jun 14, 2022

Thanks, I didn't install Win 10 SDK (instead installed Win 11 SDK).
But now I have another error

-- Generating done
-- Configuring done
CMake Error: CMake can not determine linker language for target: UICatalog
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_Swift_FLAGS


CMake Generate step failed.  Build files cannot be regenerated correctly.

@Higher08
Copy link
Author

With swift build build succeeded, but .build directory is not even created and because of that it is unable to create symbolic link unable to create symbolic link
unable to create symbolic link at C:\Users\Dmytro\Documents\swiftdev\swift-win32\.build\debug: Error Domain=NSCocoaErrorDomain Code=256 "(null)"

@compnerd
Copy link
Owner

I think that you’re using an older CMake. Make sure that you’re using the latest release.

The symlink error is not due to the directory not existing. You are not running as administrator nor do you have a GPO applied to allow you to create symbolic links. Yet another alternative is to enable developer mode.

This is all due to setup issues, most of this is covered in depth on the swift forums. Please search through them in the future.

@Higher08
Copy link
Author

It was not a problem with the installation. I ran the Cmake from the folder of the project itself, but I needed swift-win32. Maybe add this to the readme because it seems non-obvious?
Thanks, running x64 native tools as an administrator helped (although I had developer mode already enabled)

@compnerd
Copy link
Owner

Patches to improve the documentation are welcome :)

@Higher08
Copy link
Author

Ok, I will open PR later)
Do I understand correctly that I can’t run an exe on a system without swift installed, even if I copy all the dlls?

@compnerd
Copy link
Owner

The generated binary can be run on other Windows 10 machines if you copy the runtime and the other DLLs. The runtime redistributable is packaged as a separate MSI though it's not available as a separate download currently.

@Higher08
Copy link
Author

So, Swift doesn't allow to generate fat binaries with runtime like .net?

@compnerd
Copy link
Owner

Correct. Static linking isn't yet possible for Windows, so that is also not yet an option. You should be able to build tooling to package up the dependencies though (this was the approach that Swift used initially on other platforms as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants