jonas-k
jonas-k

Reputation: 141

How to link against frameworks that are not in the standard location?

I tried to link against a private framework in /System/Library/PrivateFrameworks using

#[link(name = "MultitouchSupport", kind = "framework")]

But the linker tells me that the MultitouchSupport framework was not found. I also tried

#[link(name = "/System/Library/PrivateFrameworks/MultitouchSupport", kind = "framework")]

and

#[link(name = "/System/Library/PrivateFrameworks/MultitouchSupport.framework", kind = "framework")]

with the file extension, but neither work.

Is it even possible to link against frameworks that are not in the standard location of /System/Library/Frameworks?

Upvotes: 11

Views: 1603

Answers (1)

jonas-k
jonas-k

Reputation: 141

I found out that WiSaGaN's suggestion was quite close to the solution: It works if you use search=framework in the build.rs. The solution was to use the following build.rs:

fn main()
{
    println!("cargo:rustc-link-search=framework={}", "/System/Library/PrivateFrameworks");
}

Thank you, WiSaGaN!

Using this build.rs you can link as usual:

#[link(name = "MultitouchSupport", kind = "framework")]

Upvotes: 3

Related Questions