-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't cross-compile from Linux #23
Comments
You need xcode headers installed to build, no way around that fact unfortunately. |
One way for cross-compiling is to import your own raw bindings rather than using bindgen on the platform that you have no idea where those headers are. servo's core-foundation-rs is an example. You could copy the coreaudio.rs generated from this crate and replace If you're running on non-apple os, but your Specifically, you can change the non-apple-os case in build.rs like: #[cfg(not(any(target_os = "macos", target_os = "ios")))]
fn main() {
let target = std::env::var("TARGET").unwrap();
// Using the fullback raw bindings instead
if target.contains("-apple") {
println!("cargo:rustc-link-lib=framework=AudioUnit");
println!("cargo:rustc-link-lib=framework=CoreAudio");
println!("cargo:rustc-cfg=fullback_bindings");
} else {
eprintln!("{} is not a valid target for coreaudio-sys.", target);
}
} In the lib.rs, include your fullback raw bindings if the bindings doesn't be generated from the bindgen: #[cfg(fullback_bindings)]
include!("fullback_coreaudio.rs");
#[cfg(not(fullback_bindings))]
include!(concat!(env!("OUT_DIR"), "/coreaudio.rs")); and the fullback raw bindings(fullback_coreaudio.rs here) may look like // Replace #[link = "...../SDKs/MacOSX.sdk/System/Library/Frameworks/AudioUnit"]
#[link(name = "AudioUnit", kind = "framework")]
// Replace #[link = "...../SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio"]
#[link(name = "CoreAudio", kind = "framework")]|
// Replace #[link = "...../SDKs/MacOSX.sdk/System/Library/Frameworks/XXXX"]
#[link(name = "XXXX", kind = "framework")]|
...
// The following code is copied from coreaudio.rs generated from the bindgen
...
...
...
pub const TARGET_OS_MAC : u32 = 1 ; .... Hope this helps. |
I am getting the same exact issue, but I do have the MacOS headers ( the whole SDK and the cross-compiler toolchain built with osxcross ). What I'm confused at is that the message Also, after patching the build.rs script for this repo and hardcoding the path to the frameworks path, I still get an error:
It looks like it just isn't adding the |
It's very likely that to get this working with iOS there might be some tweaking necessary, as I've only tested this with macOS since the last bindgen update. Very open to PRs for both fallback bindings and any tweaks required to get iOS working! |
I got this to compile on my Linux system for Mac with the following diff to the diff --git a/build.rs b/build.rs
index 2974293..0ab4036 100644
--- a/build.rs
+++ b/build.rs
@@ -140,6 +140,7 @@ fn build(frameworks_path: &str) {
// Generate the bindings.
let bindings = builder
+ .clang_args(&["-I/System/Library/Frameworks/Kernel.framework/Headers", "-I/build/osxcros
s/target/SDK/MacOSX10.11.sdk/usr/include"])
.trust_clang_mangling(false)
.derive_default(true)
.rustfmt_bindings(false)
@@ -152,16 +153,16 @@ fn build(frameworks_path: &str) {
.expect("could not write bindings");
}
-#[cfg(any(target_os = "macos", target_os = "ios"))]
+//#[cfg(any(target_os = "macos", target_os = "ios"))]
fn main() {
- if let Ok(directory) = frameworks_path() {
- build(&directory);
- } else {
- eprintln!("coreaudio-sys could not find frameworks path");
- }
+ //if let Ok(directory) = frameworks_path() {
+ build("/System/Library/Frameworks");
+ //} else {
+ //eprintln!("coreaudio-sys could not find frameworks path");
+ //}
}
-#[cfg(not(any(target_os = "macos", target_os = "ios")))]
-fn main() {
- eprintln!("coreaudio-sys requires macos or ios target");
-}
+//#[cfg(not(any(target_os = "macos", target_os = "ios")))]
+//fn main() {
+ //eprintln!("coreaudio-sys requires macos or ios target");
+//} So first I have to understand why building with Second @mitchmindtree what do you think about reading from a I'm good submitting a PR for a way to make this work, I just need to know how we want to handle this. |
I think I just figured out why this isn't correctly detecting that I'm building for MacOS:
The problem with the line above is that the Edit: We can use the |
Hi!
I tried to compile an Amethyst (mini) game for macos from my Linux, since I don't have a mac but some of my friends do. Here are my commands:
Everything went fine until:
In
./target/x86_64-apple-darwin/release/build/coreaudio-sys-a35cb65331eb6c13/
, there is this error:Any ideas on how I can fix this? On the 368 dependencies, at least 360 do compile, so I guess that it's not the only crate that does bindings.
The text was updated successfully, but these errors were encountered: