Closed burak0206 closed 1 year ago
Interestingly the generated libpaho-mqtt3as.a is a fat
binary already....
target/release/build/paho-mqtt-sys-78ae08bf9e76abb2/out/lib/libpaho-mqtt3as.a: Mach-O universal binary with 2 architectures: [x86_64:current ar archive random librarycurrent ar archive random library] [arm64:current ar archive random librarycurrent ar archive random library]
target/release/build/paho-mqtt-sys-78ae08bf9e76abb2/out/lib/libpaho-mqtt3as.a (for architecture x86_64): current ar archive random library
target/release/build/paho-mqtt-sys-78ae08bf9e76abb2/out/lib/libpaho-mqtt3as.a (for architecture arm64): current ar archive random library
Could that be the issue?
there was a recent PR merged in rust... https://github.com/rust-lang/rust/pull/98736. Looks like it is targeted for the 1.66 release of the rust toolchain
checked it with the beta toolchain just now. it builds for both architectures on my M1 :)
good news!, I will try it @appelgriebsch
I tried to these instructions set and I can compile. thank you @appelgriebsch
1) rustup update && rustup update beta && rustup install beta
2) rustup default beta-aarch64-apple-darwin
3) rustup target add x86_64-apple-darwin
4) cargo clean && cargo build --target x86_64-apple-darwin
I tried to these instructions set and I can compile. thank you @appelgriebsch
1. rustup update && rustup update beta && rustup install beta 2. rustup default beta-aarch64-apple-darwin 3. rustup target add x86_64-apple-darwin 4. cargo clean && cargo build --target x86_64-apple-darwin
instead of making the beta
channel the default one you can also prefix the cargo
commands with the channel to be used:
cargo +beta target add x86_64-apple-darwin
cargo +beta build --target x86_64-apple-darwin
You can then use the lipo
command to combine both binaries into a single universal (fat) binary like so:
lipo -create -arch arm64 <path-to-aarch64-apple-darwin-binary> -arch x86_64 <path-to-x86_64-apple-darwin-binary> -o <path-to-universal-binary>
Benefit: this universal binary works for both architectures.
Hey! Thanks for the work on this. I don't have access to an M1 to help or try any of it out, but do you think there is something here we should add to the README.md? Maybe make a Mac/M1 section?
Hi @fpagliughi ,
yes it can be nice, I can add if you want. but I don't know which one is the best. I think @appelgriebsch knows better than me.
Sorry for radio silence. Was a bit busy lately. Will provide a PR for the README update on the coming weekend.
Hi all, I am developing a rust web project using the M1 pro chipset. I installed mosquitto with brew and paho.mqtt.c with macports. I added paho-mqtt-sys and paho-mqtt. Before that, application can be built. However if I add paho-mqtt libraries, It gives an error when I call cargo build --target x86_64-apple-darwin.
What should I do to fix the error?
Error: