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

Spurious "error: could not find native static library objc, perhaps an -L flag is missing?" on macOS Big Sur #96943

Open
adaszko opened this issue May 11, 2022 · 2 comments · May be fixed by #131477
Labels
C-bug Category: This is a bug. O-macos Operating system: macOS

Comments

@adaszko
Copy link
Contributor

adaszko commented May 11, 2022

Hi 👋

I'm experiencing this issue on macOS Big Sur when libusb1-sys crate's build.rs invokes pkg-config and gets this:

$ pkg-config --static --libs /usr/local/Cellar/libusb/1.0.26/lib/pkgconfig/libusb-1.0.pc
-L/usr/local/Cellar/libusb/1.0.26/lib -lusb-1.0 -lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation -Wl,-framework,Security

rustc seems then proceed to try to link libobjc:

$ [...] cargo build
   Compiling libusb1-sys v0.6.2 (/Users/adaszko/repos/rusb/libusb1-sys)
   Compiling rusb v0.9.1
error: could not find native static library `objc`, perhaps an -L flag is missing?

This issue is preventing me from building a statically linked libusb1-sys. Linking itself should still work, it's just that rustc's erroring out prevents the pipeline from getting to the linking step AFAICT.

EDIT: Sorry, I've removed a misleading points about dynamic linking stemming from my misunderstanding of the issue.

@madsmtm
Copy link
Contributor

madsmtm commented Oct 10, 2024

I suspect this may have been caused by not properly passing the macOS SDK to the linker, which will be fixed by #131477.

In the meantime, could you try doing xcrun cargo build, to ensure that SDKROOT is set?

@adaszko
Copy link
Contributor Author

adaszko commented Oct 10, 2024

Sorry, I'm no longer working on this (it's been a while) so won't be able to test it. Unless someone else is affected I think the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-macos Operating system: macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants