Skip to content

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

Closed

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.

Activity

  1. added a commit that references this issue on May 20, 2022
  2. madsmtm commented on Oct 10, 2024

    @madsmtm
    Member

    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?

  3. adaszko commented on Oct 10, 2024

    @adaszko
    ContributorAuthor

    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.

  4. added 5 commits that reference this issue on Aug 11, 2025
  5. added 2 commits that reference this issue on Aug 12, 2025
  6. added a commit that references this issue on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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