I'm trying to cross compile the triangle example from vulkano. I followed the 'cross-compile to windows-gnu from windows-msvc' instructions provided by them, just to make sure that I could compile the example code. but unfortunately I'm getting the following error:
Compiling vulkano-shaders v0.13.0
error: linking with gcc failed: exit code: 1
= note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "C:\Program Files\Rust stable GNU 1.36\lib\rustlib\x86_64-pc-windows-gnu\lib\dllcrt2.o" "C:\Program Files\Rust stable GNU 1.36\lib\rustlib\x86_64-pc-windows-gnu\lib\rsbegin.o" "-L" "C:\Program Files\Rust stable GNU 1.36\lib\rustlib\x86_64-pc-windows-gnu\lib"...
error: Could not compile libc.
warning: build failed, waiting for other jobs to finish...
error: Could not compile proc-macro2.
warning: build failed, waiting for other jobs to finish...
error: Could not compile arrayvec.
warning: build failed, waiting for other jobs to finish...
error: build failed
What am I doing wrong? Maybe there's a conflict in my path? I noticed that I have Mingw, Cygwin64 and msys64 installed; does this have to do with my problem?
Hi! Thanks for your comment. Yes, seems like I missed one step, I forgot to run the command that in that thread mentions: rustup component remove rust-mingw . I started from zero just to make sure, but yet the error is almost the same. I did make sure that msys64\mingw64\bin is in my path; I runned pacman -S mingw-w64-x86_64-toolchain in the msys2_shell, everything is already installed; I already have CMake too; I even copied the crt2.o and dllcrt2.o files from C:\msys64\mingw64\x86_64-w64-mingw32\lib to ~\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\li directory, like in the said issue mentions.
But I'm getting: undefined reference to '__imp___acrt_iob_func'. That was the first error that leads me to the workaround I'm following.
Here's what is inside my ./cargo/config (I'm not sure if it was necessary to modify that file, though): [target.x86_64-pc-windows-gnu] rustflags=["-Clink-args=-lworkaround_47048"]
My current toolchain is stable-x86_64-pc-windows-msvc. I'm running the triangle example with: cargo build --target x86_64-pc-windows-gnu --bin triangle
I really don't know what to do, I'm running out of ideas
I have no idea but my config file has those lines below under [target.x86_64-pc-windows-gnu] in addition to rustflags=["-Clink-args=-lworkaround_47048"] so maybe try:
linker = <mingw64 gcc path>
ar = <mingw64 ar path>
But this is the same undefined reference to __imp___acrt_iob_func error. By viewing the command line arguments, I see -lworkaround_47048 is not getting passed to the linker. Make sure your setting is read by e.g. try changing it to -ldummy_nonexist and see getting an error.
After following your instructions, the config file looks like this: [target.x86_64-pc-windows-gnu] rustflags=["-Clink-args=-ldummy_nonexist"] linker="C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe" ar="C:\\msys64\\mingw64\bin\\ar.exe"
However, the error is the same: full error here. What does this mean? I'm missing a step?
Do you have RUSTFLAGS environment variable set (echo $env:RUSTFLAGS) or is there any other .cargo/config file to your current directory or any of its ancestor directories? The configuration can be overridden.
I think I don't have that variable set. Should I run echo $env:RUSTFLAGS in Powershell to make sure? And no, that's the only .cargo/config file I have in my current directory. I would like to mention that I've been running my binary with the following command: cargo build --target=x86_64-pc-windows-gnu --bin triangle, is that correct?
This is the output after running cargo clean and then building my project again. It's complaining about CMake? I did make sure that I have C:\Program Files\CMake\bin in my path.
Thanks a lot for taking the time in trying to help me, by the way. This problem has been chasing me for days.