Skip to content

Cargo does not use output of build.rs for the bin target in projects containing both bin and lib #7506

Closed
@operutka

Description

@operutka

Problem
I have a project that was originally an application and recently I've decided to make it I also a library. The project uses a build script to link with libpcap. After I added src/lib.rs, the project stopped building.

When I run cargo with the -v option, I can see that the lib target gets build just fine but the bin target fails because the linker cannot find some symbols (contents of libpcap). I can also see that the rustc command for the lib target contains arguments -l static=net_devices -l dylib=pcap but these arguments are not present for the bin target.

I'd expect all targets to use the output of build.rs.

Steps

  1. Clone https://github.com/angelcam/arrow-client
  2. Make sure that libpcap is installed on your system
  3. Add src/lib.rs and
  4. Run cargo build --features all

Notes

Output of cargo version:
cargo 1.38.0 (23ef9a4 2019-08-20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions