error: lld-link: warning: ignoring unknown argument '-o'
lld-link: error: could not open 'build\windows\x64\release\hello.exe': no such file or directory
set_project("test")
if is_os("windows") then
set_toolset("ld", "lld-link.exe")
-- set_toolset("sh", "lld-link.exe")
end
-- hello world test
target("hello")
set_kind("binary")
add_files("main.cpp")
main.cpp👇
int main() {}
附加信息和错误日志
Result of `xmake -vD`
```
checking for platform ... windows
checking for architecture ... x64
checking for cl.exe ... D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2022
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checking for cl.exe ... D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
[ 25%]: compiling.release subproject01\src\main.cpp
"D:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\cl.exe" -c -nologo -Isubproject01\include -D_CRT_SECURE_NO_WARNINGS /EHsc -Fobuild\.objs\hello\windows\x64\release\subproject01\src\main.cpp.obj subproject01\src\main.cpp
checking for D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe ... ok
checking for flags (cl_sourceDependencies) ... ok
> cl.exe "/sourceDependencies" "D:\Scoop\apps\vscode\1.82.2\data\tmp\.xmake\230921\_1B20364676E647208587F83653BA7160.json" "-nologo"
[ 50%]: linking.release hello.exe
lld-link -o build\windows\x64\release\hello.exe build\.objs\hello\windows\x64\release\subproject01\src\main.cpp.obj
error: @programdir\modules\async\runjobs.lua:256: @programdir\actions\build\kinds\binary.lua:74: @programdir\core\sandbox\modules\os.lua:273: lld-link: warning: ignoring unknown argument '-o'
lld-link: error: could not open 'build\windows\x64\release\hello.exe': no such file or directory
stack traceback:
[C]: in function 'error'
[@programdir\core\base\os.lua:921]:
[@programdir\core\sandbox\modules\os.lua:273]: in function 'runv'
[@programdir\modules\core\tools\ld.lua:81]:
[C]: in function 'xpcall'
[@programdir\core\base\utils.lua:280]:
[@programdir\core\tool\linker.lua:224]: in function 'link'
[@programdir\actions\build\kinds\binary.lua:74]: in function 'callback'
[@programdir\modules\core\project\depend.lua:191]: in function 'on_changed'
[@programdir\actions\build\kinds\binary.lua:55]: in function '_do_link_target'
[@programdir\actions\build\kinds\binary.lua:105]:
[@programdir\actions\build\kinds\binary.lua:132]: in function '_link_target'
[@programdir\actions\build\kinds\binary.lua:160]: in function 'jobfunc'
[@programdir\modules\async\runjobs.lua:232]:
[C]: in function 'xpcall'
[@programdir\core\base\utils.lua:280]: in function 'trycall'
[@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
[@programdir\modules\async\runjobs.lua:218]: in function 'cotask'
[@programdir\core\base\scheduler.lua:404]:
stack traceback:
[C]: in function 'error'
@programdir\core\base\os.lua:921: in function 'os.raiselevel'
(...tail calls...)
@programdir\modules\async\runjobs.lua:256: in field 'catch'
@programdir\core\sandbox\modules\try.lua:123: in global 'try'
@programdir\modules\async\runjobs.lua:218: in upvalue 'cotask'
@programdir\core\base\scheduler.lua:404: in function <@programdir\core\base\scheduler.lua:397>
```
Xmake 版本
v2.8.2+HEAD.57212c681
操作系统版本和架构
Windows 11 22H2 (22624.1680)
描述问题
运行
xmake
报链接错误👇xmake -v
显示使用了错误的命令行样式(用了ld的?)翻了下代码,好像把下面这个改成
inherit("link")
就可以正确链接了 https://github.com/xmake-io/xmake/blob/5c619b17b5847b18d284323830dedaeff9d5d6ed/xmake/modules/core/tools/lld_link.lua#L22期待的结果
提供正确的命令行参数给
lld-link
,正确链接程序工程配置
xmake.lua👇
main.cpp👇
附加信息和错误日志
Result of `xmake -vD`
``` checking for platform ... windows checking for architecture ... x64 checking for cl.exe ... D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe checking for Microsoft Visual Studio (x64) version ... 2022 checkinfo: cannot runv(zig.exe version), No such file or directory checking for zig ... no checkinfo: cannot runv(zig.exe version), No such file or directory checking for zig ... no checking for cl.exe ... D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe checking for the c++ compiler (cxx) ... cl.exe [ 25%]: compiling.release subproject01\src\main.cpp "D:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\cl.exe" -c -nologo -Isubproject01\include -D_CRT_SECURE_NO_WARNINGS /EHsc -Fobuild\.objs\hello\windows\x64\release\subproject01\src\main.cpp.obj subproject01\src\main.cpp checking for D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe ... ok checking for flags (cl_sourceDependencies) ... ok > cl.exe "/sourceDependencies" "D:\Scoop\apps\vscode\1.82.2\data\tmp\.xmake\230921\_1B20364676E647208587F83653BA7160.json" "-nologo" [ 50%]: linking.release hello.exe lld-link -o build\windows\x64\release\hello.exe build\.objs\hello\windows\x64\release\subproject01\src\main.cpp.obj error: @programdir\modules\async\runjobs.lua:256: @programdir\actions\build\kinds\binary.lua:74: @programdir\core\sandbox\modules\os.lua:273: lld-link: warning: ignoring unknown argument '-o' lld-link: error: could not open 'build\windows\x64\release\hello.exe': no such file or directory stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:921]: [@programdir\core\sandbox\modules\os.lua:273]: in function 'runv' [@programdir\modules\core\tools\ld.lua:81]: [C]: in function 'xpcall' [@programdir\core\base\utils.lua:280]: [@programdir\core\tool\linker.lua:224]: in function 'link' [@programdir\actions\build\kinds\binary.lua:74]: in function 'callback' [@programdir\modules\core\project\depend.lua:191]: in function 'on_changed' [@programdir\actions\build\kinds\binary.lua:55]: in function '_do_link_target' [@programdir\actions\build\kinds\binary.lua:105]: [@programdir\actions\build\kinds\binary.lua:132]: in function '_link_target' [@programdir\actions\build\kinds\binary.lua:160]: in function 'jobfunc' [@programdir\modules\async\runjobs.lua:232]: [C]: in function 'xpcall' [@programdir\core\base\utils.lua:280]: in function 'trycall' [@programdir\core\sandbox\modules\try.lua:117]: in function 'try' [@programdir\modules\async\runjobs.lua:218]: in function 'cotask' [@programdir\core\base\scheduler.lua:404]: stack traceback: [C]: in function 'error' @programdir\core\base\os.lua:921: in function 'os.raiselevel' (...tail calls...) @programdir\modules\async\runjobs.lua:256: in field 'catch' @programdir\core\sandbox\modules\try.lua:123: in global 'try' @programdir\modules\async\runjobs.lua:218: in upvalue 'cotask' @programdir\core\base\scheduler.lua:404: in function <@programdir\core\base\scheduler.lua:397> ```