I'm working on a bigger project and have now decided to add cross compiling to it. I have created a minimum viable version of the project (Maybe 100 lines of code probably less) and uploaded it to github.
I am building a mostly rust program, with some bindings to C++ that call GLFW/Vulkan code. The demo only uses GLFW.
I added the targets via rustup:
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
rustup target add x86_64-pc-windows-gnu
I made sure to setup .cargo/config correctly
[build]
rustflags = [
"-C", "link-args=-lglfw -lstdc++",
]
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-g++"
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-g++"
I installed the appropriate linkers and build stuff:
sudo apt install libssl-dev libglfw3 libglfw3-dev clang gcc g++ cmake build-essential
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
Building it with for my native platform (Ubuntu Linux, x86_64) works just fine, the binary runs. No Issues whatsoever.
Building it for ARM Linux x64 results in the linker not finding glfw:
= note: /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglfw
collect2: error: ld returned 1 exit status
Building for Windows x86_64 results in the header not being found:
cargo:warning=csrc/basic_glfw.cpp:1:10: fatal error: GLFW/glfw3.h: No such file or directory
cargo:warning= 1 | #include <GLFW/glfw3.h>
cargo:warning= | ^~~~~~~~~~~~~~
How do I fix my project so that the project compiles to these platforms correctly?
Also I'm aware of projects like glfw-rs and ash, I would rather not use them if at all possible.