gpt4 book ai didi

c++ - 如何解决mingw-w64 MSVCRT依赖问题

转载 作者:行者123 更新时间:2023-12-01 22:27:52 25 4
gpt4 key购买 nike

我正在使用Go1.12 + msys2/mingw-w64(9.2.0)构建golang项目,它显示错误:

D:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o: in function `pre_c_init':
E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:146: undefined reference to `__p__fmode'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o: in function `__tmainCRTStartup':
E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:290: undefined reference to `_set_invalid_parameter_handler'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:299: undefined reference to `__p__acmdln'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-merr.o): in function `_matherr':
E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/merr.c:46: undefined reference to `__acrt_iob_func'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-pseudo-reloc.o): in function `__report_error':
E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/pseudo-reloc.c:149: undefined reference to `__acrt_iob_func'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/pseudo-reloc.c:150: undefined reference to `__acrt_iob_func'
collect2.exe: error: ld returned 1 exit status

经过研究,我确定这是mingw64的msvcrt兼容性问题。
我知道有这样的解决方法: unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2
但这并不能解决我所有的问题。

我尝试链接该库:LDFLAGS:-L%filepath%-llegacy_stdio_definitions,没有任何变化。

是否有补丁可以修复它,还是我必须构建自定义版本的mingw64?

最佳答案

因此,我本人回答了我的问题,此案已经结案。

是的,Mingw64使用msvcrt。

以下是一些技巧,可以帮助解决Mingw64和msvcrt之间的依赖关系问题。
主要目标是让编译器加载正确版本的MSVCRT库系列。

1.更新Mingw64。

2.在Mingw64 \ include_mingw.h(或x86_64-w64-mingw32 \ include)中 check out MSVCRT_VERSION ,确保版本号与您的Windows版本匹配或进行修改。

3.看看链接器选项,例如“#cgo LDFLAGS:-Lxxx”,不要弄乱库路径。删除任何不必要的库路径设置,让链接程序自行查找库。

  • 确保所有内容都使用相同的库构建。
  • 关于c++ - 如何解决mingw-w64 MSVCRT依赖问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58816048/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com