Skip to content

zig cc 无法为 MinGW 构建包含动态库的项目 #6006

@Doekin

Description

@Doekin

Xmake 版本

xmake v2.9.7+HEAD.2bb99e0c3

操作系统版本和架构

Windows 10

描述问题

无法使用 Zig 工具链编译含动态库的项目

期待的结果

正常使用 Zig 工具链编译含动态库的项目

工程配置

使用 XMake 动态库项目模板

$ xmake create -t shared -l c win_dll
$ cd win_dll
$ xmake f -c -vD -p mingw --toolchain=zig
$ xmake -r -vD

附加信息和错误日志

$ xmake -r -vD
checking for flags (-O3) ... ok
> cc.cmd "-O3" "-target" "x86_64-windows-gnu"
checking for flags (-DNDEBUG) ... ok
> cc.cmd "-DNDEBUG" "-target" "x86_64-windows-gnu"
[ 50%]: cache compiling.release src\foo.c
C:\Users\leemu\AppData\Local\Temp\.xmake\241225\zigcc\cc.cmd -c -target x86_64-windows-gnu -O3 -DNDEBUG -o build\.objs\foo\mingw\x86_64\release\src\foo.c.obj src\foo.c
checking for flags (-MMD -MF) ... ok
> cc.cmd "-MMD" "-MF" "C:\Users\leemu\AppData\Local\Temp\.xmake\241225\_546632DA1DBC4C508F1FC3778E7D2E80" "-target" "x86_64-windows-gnu"
checking for flags (-fdiagnostics-color=always) ... ok
> cc.cmd "-fdiagnostics-color=always" "-target" "x86_64-windows-gnu"
[ 50%]: cache compiling.release src\main.c
C:\Users\leemu\AppData\Local\Temp\.xmake\241225\zigcc\cc.cmd -c -target x86_64-windows-gnu -fvisibility=hidden -O3 -DNDEBUG -o build\.objs\win_dll\mingw\x86_64\release\src\main.c.obj src\main.c
[ 62%]: linking.release libfoo.dll
C:\Users\leemu\AppData\Local\Temp\.xmake\241225\zigcc\c++.cmd -o build\mingw\x86_64\release\libfoo.dll build\.objs\foo\mingw\x86_64\release\src\foo.c.obj -shared -target x86_64-windows-gnu -s -Wl,--out-implib,build\mingw\x86_64\release\libfoo.dll.a
[ 87%]: linking.release win_dll.exe
C:\Users\leemu\AppData\Local\Temp\.xmake\241225\zigcc\c++.cmd -o build\mingw\x86_64\release\win_dll.exe build\.objs\win_dll\mingw\x86_64\release\src\main.c.obj -target x86_64-windows-gnu -Lbuild\mingw\x86_64\release -s -lfoo
error: unable to find dynamic system library 'foo' using strategy 'paths_first'. searched paths:
  build\mingw\x86_64\release\foo.dll
  build\mingw\x86_64\release\foo.lib
  build\mingw\x86_64\release\libfoo.a
error: @programdir\core\main.lua:329: @programdir\actions\build\main.lua:148: @programdir\modules\async\runjobs.lua:325: @programdir\actions\build\kinds\binary.lua:53: @programdir\core\sandbox\modules\os.lua:378: execv(C:\Users\leemu\AppData\Local\Temp\.xmake\241225\zigcc\c++.cmd -o build\mingw\x86_64\release\win_dll.exe build\.objs\win_dll\mingw\x86_64\release\src\main.c.obj -target x86_64-windows-gnu -Lbuild\mingw\x86_64\release -s -lfoo) failed(1)
$ ls build\mingw\x86_64\release\
build\mingw\x86_64\release\libfoo.dll    build\mingw\x86_64\release\libfoo.dll.a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions