Compiling examples depending on multiple native libraries?

Hi,

how do I provide examples which depend on crates depending on different native libraries?

I've separated them in my example workspace but they doesn't compile if I add them both at the same time as examples workspace member.

error: multiple packages link to native library `sqlite3`, but a native library can be linked only once

package `libsqlite3-sys v0.9.1`
    ... which is depended on by `diesel v1.4.8`
    ... which is depended on by `databases-diesel v0.0.0...
links to native library `sqlite3`

package `libsqlite3-sys v0.23.2`
    ... which is depended on by `rusqlite v0.26.3`
    ... which is depended on by `databases-rusqlite v0.0.0...
also links to native library `sqlite3`

Where is the problem...? The linking is in different executables?

Cargo always tries to unify crate versions across workspace crates. Combined with the fact that cargo allows only one version of a crate that links a native library in your dependency tree this results in this error. There are two ways to workaround this:

  • Move your crates into different workspaces
  • Find a version of rusqlite and diesel that depend on a compatible range of versions for libsqlite3-sys. You can lookup the dependency versions on crates.io and as both crates directly depend on libsqlite3-sys that's quite easy. Diesel 1.4.8 declares the following range: >= 0.8.0, < 0.23.0. A compatible rusqulite version would be 0.25.2

Well it was way nr. 2 up to now but I don't like it.
I've tried way nr. 1 before but oversaw that some tests uses the diesel feature in dev-dependencies and so I'd to separate them also.
Already works.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.