-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Cargo does not use output of build.rs for the bin target in projects containing both bin and lib #7506
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
Comments
This is expected and intended, otherwise you would get duplicate symbols. To work with this, the code using the libraries needs to be in |
@ehuss Good to know! Thank you for the explanation. |
I want to use winres to embed icons into my bin output.But cargo only specify the resource for the lib.
compile output Running Running |
Is this true only for static libs? Could it be relaxed when dynamic linking is explicitly specified? |
See also #5881. |
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 therustc
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
src/lib.rs
andcargo build --features all
Notes
Output of
cargo version
:cargo 1.38.0 (23ef9a4 2019-08-20)
The text was updated successfully, but these errors were encountered: