Iced: cross compile game_of_life example from linux to macos

Created on 20 Sep 2020  路  2Comments  路  Source: hecrj/iced

I would like to use iced for writing utilities which will probably run on MacOS, but I'm on Linux so I'd like to be able to cross compile iced.

Before using iced, I've tried:

which worked pretty well.

Then I would like to find similar things in rust and came across iced. I made a script to cross compile https://github.com/GopherJ/cfg/blob/master/scripts/osxcross.sh, this script worked for some other libraries but I got an error in iced.

   Compiling wgpu-native v0.5.1
error: linking with `x86_64-apple-darwin14-clang` failed: exit code: 1
  |
  = note: "x86_64-apple-darwin14-clang" "-m64" "-L" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.0.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.1.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.10.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.11.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.12.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.13.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.14.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.15.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.2.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.3.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.4.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.5.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.6.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.7.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.8.rcgu.o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.wgpu_native.6kkamhy4-cgu.9.rcgu.o" "-o" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libwgpu_native-259eb0704b182ba7.dylib" "-Wl,-exported_symbols_list,/tmp/rustcJcFFXZ/list" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/wgpu_native-259eb0704b182ba7.2ls74fghvuz96pfl.rcgu.o" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs" "-L" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps" "-L" "/home/cheng/Projects/Rust/iced/target/release/deps" "-L" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/build/objc_exception-5b64af16b264bb60/out" "-L" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/build/spirv_cross-2cda498fffa447b0/out" "-L" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libwgpu_core-7a0eb1d2ec16c3e7.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libvec_map-0cdc4d1719aef91b.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libgfx_memory-b0957f5116dad517.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libslab-a8a80358c74b7aaa.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libhibitset-51a8ed710470ef93.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libatom-4e17c0803db55e2a.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libwgpu_types-6b72d275407aeb2c.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libpeek_poke-636dcdf68cfe553c.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libgfx_descriptor-02416bbcba2108f5.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libgfx_backend_metal-fd2d5871df34aa8f.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libstorage_map-8b969022a494c6f5.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libcopyless-11263fcc7f845c81.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libgfx_auxil-40d08a5187d9196d.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libfxhash-401e829a170f5be0.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libbyteorder-ab8d11b47d17436b.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libspirv_cross-60cbb27da3f217dc.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libarrayvec-724353cd69c1d476.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libparking_lot-ddde31b9da9359bf.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libparking_lot_core-bbb77b6192a2bb78.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libsmallvec-b98c81b250f221c1.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/liblock_api-abc2b1410dc340cb.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libscopeguard-2f6bc472ecc1519b.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libmetal-f6a5dc9a853d52f9.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/liblazy_static-e63e0bd2d580c996.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libcocoa-8d9559fa2f0b20c7.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libcore_graphics-c9ef86c602b3f02d.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libforeign_types-484b6ff8f3831cb4.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libforeign_types_shared-07c0f0c2102950eb.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libcore_foundation-34c585b011cd9620.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libcore_foundation_sys-28f40862754da4ca.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libblock-590436d5f0eb89e6.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/librange_alloc-6fdfd7889cb68997.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libobjc-febcccb4db4626d9.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libmalloc_buf-58fbf4f1d52fba23.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libgfx_backend_empty-21e0815140cced69.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/liblog-032b4d7c87d5ce65.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libcfg_if-5d7f3510936b3ebf.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libgfx_hal-ea6185a4ef28cd6b.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libraw_window_handle-aad9bef18864c577.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/liblibc-3507ae351ab28dbd.rlib" "/home/cheng/Projects/Rust/iced/target/x86_64-apple-darwin/release/deps/libbitflags-53d97153ceb1e7b6.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libstd-8b17b186cd972395.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-d06c699b1a1b11b4.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-65f6b0602eb03a82.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-cbfad1c2e76ceaeb.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-6e499767504f2786.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-767e350fd8547e78.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-9ecb8e821171ea10.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libunwind-c11544637ad3758f.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-2e3b92524ee7eda9.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/liblibc-628a35dcde52dad2.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/liballoc-f99de1eca1e6e970.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-ef5998790eeac756.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcore-3fe78a4d2924ae43.rlib" "/home/cheng/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-57149daefc485a08.rlib" "-lc++" "-framework" "Metal" "-lSystem" "-framework" "AppKit" "-framework" "AppKit" "-framework" "Foundation" "-framework" "Foundation" "-framework" "QuartzCore" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreFoundation" "-lSystem" "-lobjc" "-lSystem" "-lresolv" "-lc" "-lm"
  = note: ld: framework not found Metal
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: aborting due to previous error

error: could not compile `wgpu-native`.

To learn more, run the command again with --verbose.

I'm wondering if there is a solution for this or I must prepare a MacOS environment

question

Most helpful comment

I have not successfully cross-compiled a Rust project before. Maybe someone with more experience could chime in. However, you could use GitHub CI to build your macOS binaries!

For instance, the todos example in this repository is compiled for Windows, macOS, and Linux every time a commit is pushed to master and the resulting binaries can be downloaded as build artifacts. Feel free to grab the workflow file as a starting point.

All 2 comments

I have not successfully cross-compiled a Rust project before. Maybe someone with more experience could chime in. However, you could use GitHub CI to build your macOS binaries!

For instance, the todos example in this repository is compiled for Windows, macOS, and Linux every time a commit is pushed to master and the resulting binaries can be downloaded as build artifacts. Feel free to grab the workflow file as a starting point.

I highly recommend you use cross from the rust-embedded peeps. It has allowed me cross-compile programs directly using the winapi from Linux to Windows (as I mainly develop in WSL)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

casperstorm picture casperstorm  路  3Comments

michael-hart picture michael-hart  路  4Comments

aentity picture aentity  路  4Comments

Gohla picture Gohla  路  4Comments

olanod picture olanod  路  4Comments