Mingw cross compiling error - undefined reference to `__mingw_get_msvcrt_handle'


#1

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.

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.

The command line is:

/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

These are the error messages:

/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