You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Winlibs MinGW(GCC 14.1)中std::println/print编译失败求助

GCC 14.1 <print>库链接错误排查

我在测试GCC 14.1的新<print>库时,编译包含std::println()的程序遇到了以下链接错误(已隐去用户目录名):

C:/Users/name/Documents/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\name\AppData\Local\Temp\ccFbwKqp.o:testing.cpp:(.text$_ZSt14vprint_unicodeP6_iobufSt17basic_string_viewIcSt11char_traitsIcEESt17basic_format_argsISt20basic_format_contextINSt8__format10_Sink_iterIcEEcEE[_ZSt14vprint_unicodeP6_iobufSt17basic_string_viewIcSt11char_traitsIcEESt17basic_format_argsISt20basic_format_contextINSt8__format10_Sink_iterIcEEcEE]+0x107): undefined reference to `std::__open_terminal(_iobuf*)'
C:/Users/name/Documents/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\name\AppData\Local\Temp\ccFbwKqp.o:testing.cpp:(.text$_ZSt14vprint_unicodeP6_iobufSt17basic_string_viewIcSt11char_traitsIcEESt17basic_format_argsISt20basic_format_contextINSt8__format10_Sink_iterIcEEcEE[_ZSt14vprint_unicodeP6_iobufSt17basic_string_viewIcSt11char_traitsIcEESt17basic_format_argsISt20basic_format_contextINSt8__format10_Sink_iterIcEEcEE]+0x240): undefined reference to `std::__write_to_terminal(void*, std::span<char, 18446744073709551615ull>)'
collect2.exe: error: ld returned 1 exit status

我的编译器是winlibs提供的预编译版本,具体为x86_64-posix-seh架构,GCC 14.1.0搭配LLVM 18.1.5、mingw-w64ucrt 11.0.1的r1版本,之前使用该编译器从未出现问题。我在在线编译器Compiler Explorer上编译相同代码可以正常运行,但本地机器却出现上述链接错误。

最小可复现示例

编译命令:

g++ -std=c++2c -o testing testing.cpp

代码:

#include <print>
int main()
{
    std::println("hello world");
}

内容的提问来源于stack exchange,提问作者SHIPWECK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 15:03:10