Skip to content

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

@adaszko

Description

@adaszko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-macosOperating system: macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions