Cross-compiling a #Rust project that has custom build scripts that build C/C++ dependencies is an absolute clusterfuck!

I'm trying to cross-compile a Rust project from #Linux -> #Windows (x86_64-pc-windows-gnu) and I get walls of errors!

Some I could already fix by setting env vars to different compilers (gcc, g++, oh my!), but now I'm stuck. Maybe some missing compiler flags to gcc?

Or could it be related to this?
=> https://stackoverflow.com/a/53635241

#Help #RustLang#CrossCompile#CrossCompilation

Output of the terminal after cross-compiling the whisper-rs crate from Linux to Windows (warning: the output is very long):

  -- Detecting C compiler ABI info - failed
     Called from: [3]   /usr/share/cmake-3.28/Modules/CMakeDetermineCompilerABI.cmake
                  [2]   /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake
                  [1]   /home/jan/Dev-Projects/repos/talky/target/x86_64-pc-windows-gnu/release/build/whisper-rs-sys-90a1c9a45fb90ba6/out/whisper.cpp/CMakeLists.txt
  -- Check for working C compiler: /usr/bin/gcc
     Called from: [3]   /usr/share/cmake-3.28/Modules/CMakeTestCompilerCommon.cmake
                  [2]   /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake
                  [1]   /home/jan/Dev-Projects/repos/talky/target/x86_64-pc-windows-gnu/release/build/whisper-rs-sys-90a1c9a45fb90ba6/out/whisper.cpp/CMakeLists.txt
  -- Check for working C compiler: /usr/bin/gcc - broken
     Called from: [3]   /usr/share/cmake-3.28/Modules/CMakeTestCompilerCommon.cmake
                  [2]   /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake
                  [1]   /home/jan/Dev-Projects/repos/talky/target/x86_64-pc-windows-gnu/release/build/whisper-rs-sys-90a1c9a45fb90ba6/out/whisper.cpp/CMakeLists.txt
  -- Configuring incomplete, errors occurred!

  --- stderr
  ./whisper.cpp/ggml/include/ggml.h:210:10: fatal error: 'stdio.h' file not found
Output of the terminal after cross-compiling the whisper-rs crate from Linux to Windows (warning: the output is very long): -- Detecting C compiler ABI info - failed Called from: [3] /usr/share/cmake-3.28/Modules/CMakeDetermineCompilerABI.cmake [2] /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake [1] /home/jan/Dev-Projects/repos/talky/target/x86_64-pc-windows-gnu/release/build/whisper-rs-sys-90a1c9a45fb90ba6/out/whisper.cpp/CMakeLists.txt -- Check for working C compiler: /usr/bin/gcc Called from: [3] /usr/share/cmake-3.28/Modules/CMakeTestCompilerCommon.cmake [2] /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake [1] /home/jan/Dev-Projects/repos/talky/target/x86_64-pc-windows-gnu/release/build/whisper-rs-sys-90a1c9a45fb90ba6/out/whisper.cpp/CMakeLists.txt -- Check for working C compiler: /usr/bin/gcc - broken Called from: [3] /usr/share/cmake-3.28/Modules/CMakeTestCompilerCommon.cmake [2] /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake [1] /home/jan/Dev-Projects/repos/talky/target/x86_64-pc-windows-gnu/release/build/whisper-rs-sys-90a1c9a45fb90ba6/out/whisper.cpp/CMakeLists.txt -- Configuring incomplete, errors occurred! --- stderr ./whisper.cpp/ggml/include/ggml.h:210:10: fatal error: 'stdio.h' file not found

Ha! After installing the package and setting the env variables

export CXX=x86_64-w64-mingw32-g++
export CC=x86_64-w64-mingw32-gcc

the error is gone...

...but ofc I get a new error 😅

error: could not find native static library ggml, perhaps an -L flag is missing?

Note: I'm trying to cross-compile whisper-rs, which uses whisper.cpp, which uses ggml:

https://github.com/ggml-org/whisper.cpp

Maybe I need to do this, but how from cargo?
=> https://github.com/ggml-org/whisper.cpp/issues/168

Urgh, such a waste of time...😮‍💨

@sgued