mingw交叉编译错误-未定义对__mingw_get_msvcrt_handle的引用 [英] mingw cross compiling error - undefined reference to `__mingw_get_msvcrt_handle'

查看:209
本文介绍了mingw交叉编译错误-未定义对__mingw_get_msvcrt_handle的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过一个简单的hello world程序成功地从Windows的Linux交叉编译一个exe.现在,我试图交叉编译一个更复杂的程序.这是一个Rust程序,但这不是问题的原因,因为产生了.o.

I can successfully cross compile an exe from Linux for Windows of a simple hello world program. Now, I am trying to cross compile a more complicated program. It's a Rust program, but it is not the cause of the issue, as an .o has been produced.

您知道为什么我会得到对<__ mingw_get_msvcrt_handle'的未定义引用吗?我使用的是由 rubenvb-4.7.0预构建的工具链.

Any idea why I get an undefined reference to `__mingw_get_msvcrt_handle' error? I am using a toolchain prebuilt by rubenvb-4.7.0.

命令行为:

/inst_temp/mingw32_3/mingw64/bin/x86_64-w64-mingw32-gcc -Wl,--enable-long-section-names -fno-use-linker-plugin -Wl,--nxcompat -static-libgcc -m64 -L /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib /rust.code/study/prj3/target/x86_64-pc-windows-gnu/debug/study_cross_rust.0.o -o /rust.code/study/prj3/target/x86_64-pc-windows-gnu/debug/study_cross_rust.exe -Wl,--gc-sections -L /rust.code/study/prj3/target/x86_64-pc-windows-gnu/debug -L /rust.code/study/prj3/target/x86_64-pc-windows-gnu/debug/deps -L /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib -L /rust.code/study/prj3/.rust/lib/x86_64-pc-windows-gnu -L /rust.code/study/prj3/lib/x86_64-pc-windows-gnu -Wl,-Bstatic -Wl,-Bdynamic /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd-35c36e89.rlib /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/libcollections-35c36e89.rlib /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_unicode-35c36e89.rlib /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/librand-35c36e89.rlib /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc-35c36e89.rlib /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc_jemalloc-35c36e89.rlib /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/liblibc-35c36e89.rlib /mytool/var/lib/rustlib/x86_64-pc-windows-gnu/lib/libcore-35c36e89.rlib -l ws2_32 -l userenv -l advapi32 -l compiler-rt

这些是错误消息:

/inst_temp/mingw32_3/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o: In function `__mingw_prepare_except_for_msvcr80_and_higher':
/home/ruben/mingw-w64/toolchain/src/mingw-w64/tags/v2.0.3/mingw-w64-crt/crt/crtexe.c:430: undefined reference to `__mingw_get_msvcrt_handle'
collect2: error: ld returned 1 exit status

推荐答案

我发现了问题.

我指的是这篇文章交叉编译.要具有用于x86_64的 rustlib ,我下载了软件包 http://static.rust-lang.org/dist/rustc-1.5.0-x86_64-pc-windows-gnu.tar.gz 并复制lib到我在Linux中的rustc安装下的 rustlib/x86_64-pc-windows-gnu .

I was referring to this post for the cross compilation. To have the rustlib for x86_64, I download the package http://static.rust-lang.org/dist/rustc-1.5.0-x86_64-pc-windows-gnu.tar.gz and copy the lib to the rustlib/x86_64-pc-windows-gnu under my rustc installation in Linux.

但是,在rustlang的rustlib中未定义__mingw_get_msvcrt_handle.我正在使用 mingw gcc 的交叉编译器,看来您必须使用mingw gcc提供的库.

However, the __mingw_get_msvcrt_handle is not defined in this rustlib from rustlang. I am using the cross compiler of mingw gcc and it seems that you must use the lib provided by mingw gcc.

我的解决方案是将mingw gcc lib文件夹中的所有文件(* .a,*.o等)复制到rustlib/x86_64-pc-windows-gnu.然后就可以了.

My solution is to copy all files (*.a, *.o, etc) in mingw gcc lib folder to the rustlib/x86_64-pc-windows-gnu. It works then.

这篇关于mingw交叉编译错误-未定义对__mingw_get_msvcrt_handle的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆