Closed 24bit-xjkp closed 2 weeks ago
要使用gcc工具链编译Windows上的包需要使用mingw平台(一些包不支持cross平台),但gcc工具链可以独立安装,此时系统中不存在mingw相关环境,包括mingw32-make.exe。而xmake在mingw平台上默认需要该工具
既然不存在 mingw 环境,就不要设置 -p mingw
, 那个是专门给 mingw 平台构建用的。
xmake内建的clang和gcc工具链的c++工具链定义中,clang和gcc的定义先于clang++和g++,这会导致在mingw平台上使用上述工具链时,在链接阶段错误的使用clang和gcc去链接c++文件,导致缺少c++标准库进而链接失败。
走 -p cross
交叉编译就不会存在这个问题。
设置成 cross,但有些包限制了。。
有挺多包描述不支持cross平台的,或者改成包默认支持cross平台?
Bot detected the issue body's language is not English, translate it automatically.
Title: cmake package compilation problem on MinGW platform
Bot detected the issue body's language is not English, translate it automatically.
To use the gcc tool chain to compile packages on Windows, you need to use the mingw platform (some packages do not support the cross platform), but the gcc tool chain can be installed independently. At this time, there is no mingw related environment in the system, including mingw32-make.exe. xmake requires this tool by default on the mingw platform
Since there is no mingw environment, do not set -p mingw
, which is specially used for building the mingw platform.
In the c++ toolchain definition of the built-in clang and gcc toolchains in To link the c++ file, the c++ standard library is missing and the link fails.
Cross-compiling with -p cross
will not have this problem.
Bot detected the issue body's language is not English, translate it automatically.
Set to cross, but some packages have restrictions. .
Bot detected the issue body's language is not English, translate it automatically.
There are quite a few package descriptions that do not support the cross platform. Or should the package be changed to support the cross platform by default?
试下这个 patch. https://github.com/xmake-io/xmake/pull/5521
local mingw = assert(package:build_getenv("mingw") or package:build_getenv("sdk"), "mingw not found!")
要用ninja了说明没mingw环境了,这里是不是不应该用断言了?可以改为
local mingw = package:build_getenv("mingw") or package:build_getenv("sdk") or ""
再试试
Bot detected the issue body's language is not English, translate it automatically.
try again
现在可以正常使用了
Bot detected the issue body's language is not English, translate it automatically.
Now it can be used normally
Xmake 版本
xmake v2.9.4+HEAD.e85b001f1
操作系统版本和架构
Windows 11 24H2
描述问题
mingw32-make.exe
。而xmake在mingw平台上默认需要该工具。期待的结果
工程配置
附加信息和错误日志
注意到链接时使用的是
D:\\Tools\\clang\\bin\\clang.exe
而不是clang++
。