Comments (10)
This is expected given the incorrect invocation. You need to ensure that -sdk <path to sdk>
(which should be something like -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
). There is the %SDKROOT%
environment variable that has the path, and you can do something like:
set SWIFTFLAGS=-sdk %SDKROOT%
cmake -B build -D CMAKE_BUILD_TYPE=Release -D BUILD_TESTING=YES -D CMAKE_Swift_FLAGS=%SWIFTFLAGS% -G Ninja -S .
Note that the need for release builds is due to the debug Swift standard library not being included, and that will cause run time issues due to a mismatch between the C library ABI.
from swift-cmake-examples.
Bleh; I didn't realize that the instructions didn't cover Windows. I've updated the documentation at https://github.com/compnerd/swift-cmake-examples/tree/main/HelloWorld that you likely grabbed the commands from. Could you please report if they help?
from swift-cmake-examples.
After I used the command set SWIFTFLAGS=-sdk %SDKROOT
, get result of echo %SWIFTFLAGS%
is -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
But when I used cmake -B build -D CMAKE_BUILD_TYPE=Release -D BUILD_TESTING=YES -G Ninja -S .
, the failure is comming.
-- The C compiler identification is Clang 10.0.0 with GNU-like command-line
-- The Swift compiler identification is Apple 5.3.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working Swift compiler: C:/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe
-- Check for working Swift compiler: C:/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/CMakeTestSwiftCompiler.cmake:41 (message):
The Swift compiler
"C:/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Administrator/Desktop/swift-cmake-examples/HelloWorld/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~1/CMake/bin/ninja.exe cmTC_df535 && [1/1] Linking Swift executable cmTC_df535.exe
FAILED: cmTC_df535.exe CMakeFiles/cmTC_df535.dir/main.swift.obj cmTC_df535.swiftmodule
cmd.exe /C "cd . && C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -output-file-map CMakeFiles\cmTC_df535.dir\\output-file-map.json -incremental -j 8 -emit-executable -o cmTC_df535.exe -emit-dependencies main.swift
&& cd ."
clang: error: no such file or directory: 'C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\windows\x86_64\swiftrt.obj'
:0: error: link command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Administrator/Desktop/swift-cmake-examples/HelloWorld/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Administrator/Desktop/swift-cmake-examples/HelloWorld/build/CMakeFiles/CMakeError.log".
Likely, there is nothing changed.
from swift-cmake-examples.
Yes, nothing has changed because you need to do a clean build. You should clear away build (rd /s /q build
) first. I should've mentioned that. Its a quirk of how cached variables work with CMake.
from swift-cmake-examples.
thanks. But there is still report that error. Even I restart my pc, the error still exists.
Could I use the vscode's cmd terminal to execute cmds?
from swift-cmake-examples.
I had do my best to try, but i can't find the right way. could you do me a favour?
from swift-cmake-examples.
The VSCode terminal could work, but it may require additional setup to ensure that the VS setup is complete. If the output is identical, it implies that the swift flags have not been passed to CMake. Note that you are missing the required argument in the CMake invocation:
cmake -B build -D CMAKE_BUILD_TYPE=Release -D BUILD_TESTING=YES -D CMAKE_Swift_FLAGS=%SWIFTFLAGS% -G Ninja -S .
from swift-cmake-examples.
Thanks. I am using the vscode cmd terminal to do this.
Now, I execute set SWIFTFLAGS=-sdk %SDKROOT%
and cmake -B build -D CMAKE_BUILD_TYPE=Release -D BUILD_TESTING=YES -D CMAKE_Swift_FLAGS=%SWIFTFLAGS% -G Ninja -S .
This error changed. Now the error is:
It fails with the following output:
Change Dir: C:/Users/Administrator/Desktop/swift-cmake-examples/HelloWorld/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~1/CMake/bin/ninja.exe cmTC_8622a && [1/1] Linking Swift executable cmTC_8622a.exe
FAILED: cmTC_8622a.exe CMakeFiles/cmTC_8622a.dir/main.swift.obj cmTC_8622a.swiftmodule
cmd.exe /C "cd . && C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -output-file-map CMakeFiles\cmTC_8622a.dir\\output-file-map.json -incremental -j 8 -emit-executable -o cmTC_8622a.exe -emit-dependencies C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk main.swift && cd ."
clang: error: no such file or directory: 'C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\windows\x86_64\swiftrt.obj'
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (project)
and the CMakeLists.txt:4 in Hellow world project is project(SwiftDemo LANGUAGES C Swift)
My VS individual component is the all in swift.org quick start page.
Do you have any idea about this?
from swift-cmake-examples.
There is something wrong with your invocation still. I cannot tell what it is because it doesn't show up in the snippets that you've posted.
The swift flags are incorrect. You are missing -sdk
in front of the SDKROOT.
from swift-cmake-examples.
Bingo, i succeed finally.
I find the right way to run it at your other github repo:swift-build
Thank you very very very much.
from swift-cmake-examples.
Related Issues (15)
- Build failure using Ninja generator HOT 4
- CMAKE_Swift_COMPILER HOT 7
- Cmake with packages HOT 3
- Support for C code? HOT 8
- Build failure: unknown argument: '-static' HOT 2
- Failing to build on Windows HOT 6
- Support for use with XCode? HOT 1
- Build HelloWorld and HelloMini failed HOT 6
- CMake problem when building HelloWorld project HOT 9
- Failed to compile HelloWorld HOT 7
- `aux_source_directory ` can't find *.swift sources HOT 2
- Test fails HOT 2
- Problems while using on macOS HOT 1
- CCore is useless HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-cmake-examples.