首页 文章

mingw交叉编译错误 - 未定义引用`__mingw_get_msvcrt_handle'

提问于
浏览
0

我可以成功地从Linux for Linux交叉编译一个简单的hello world程序的exe . 现在,我正在尝试交叉编译一个更复杂的程序 . 这是一个Rust程序,但它不是问题的原因,因为.o已经生成了 .

知道为什么我会收到 undefined reference to `__mingw_get_msvcrt_handle' 错误吗?我正在使用 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

2 回答

  • 1

    我发现了这个问题 .

    我指的是this post用于交叉编译 . 要获得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 .

    但是,这个来自rustlang的rustlib中没有定义__mingw_get_msvcrt_handle . 我正在使用 mingw gcc 的交叉编译器,似乎你必须使用mingw gcc提供的lib .

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

  • -1

    在Windows上进行编译时,强烈建议使用multirust而不仅仅是rust . 它看起来像你试图以某种方式混合使用msvc编译生锈和mingw . 没有更多的信息,它不是很清楚如何/在哪里出错 .

相关问题