Skip to content
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

Usage of system frameworks (macOS)? #1347

Open
chirok11 opened this issue Dec 5, 2023 · 3 comments
Open

Usage of system frameworks (macOS)? #1347

chirok11 opened this issue Dec 5, 2023 · 3 comments

Comments

@chirok11
Copy link

chirok11 commented Dec 5, 2023

Describe the bug
Is it possible to use system frameworks on macOS? I suppose that there is a same problem while using Windows API header files on Windows.

To Reproduce
Create a demo.h file within contents:

#pragma once
#include <CoreFoundation/CoreFoundation.h>
CFRunLoopRef GetCurrentLoop() { return CFRunLoopGetCurrent(); }

Error

--- stderr
  src/demo.h:3:10: fatal error: 'CoreFoundation/CoreFoundation.h' file not found
  src/demo.h:3:10: note: did not find header 'CoreFoundation.h' in framework 'CoreFoundation' (loaded from '/System/Library/Frameworks')
  Error:   × the include_cpp! macro couldn't be expanded into Rust bindings to C++:
    │ Bindgen was unable to generate the initial .rs bindings for this file.
    │ This may indicate a parsing problem with the C++ headers.

Expected behavior
Everything is compiled.

@DDRBoxman
Copy link

I haven't had a change to dig into how things get passed to bindgen within the autocxx tools, but this post seems to have relevance for getting the path programmatically.

https://zameermanji.com/blog/2021/7/13/using-bindgen-with-system-frameworks-on-macos/

@DDRBoxman
Copy link

    let mut b = autocxx_build::Builder::new("src/main.rs", &[&path])
    .extra_clang_args(&["-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk"])
    .build()?;
   
    b.flag_if_supported("-std=c++14")
     .compile("autocxx-demo"); // arbitrary library name, pick anything

Throw this in your build script it should work.

@DDRBoxman
Copy link

Obviously needs to call like xcrun --sdk macosx --show-sdk-path to get the path first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants