0

Assuming this code:

extern crate glib;

fn main() { 

When I cargo run I get this error:

error[E0463]: can't find crate for `glib`
  --> src/main.rs:17:1
   |
17 | extern crate glib;
   | ^^^^^^^^^^^^^^^^^^ can't find crate

My Cargo.toml looks like

[dependencies]
gtk = { git = "https://github.com/gtk-rs/gtk" }

[features]
default = ["gtk/v3_10"]

glib does not appear. If I add it:

[dependencies]
gtk = { git = "https://github.com/gtk-rs/gtk" }
glib = "0.1.3"

[features]
default = ["gtk/v3_10"]

I get this error:

error: native library `glib` is being linked to by more than one package, and can only be linked to by one package

How can I fix this error? What does it mean and why it is displayed?

I have looked at Cargo.lock and it seems to have name =" glib " but I do not know how to handle this situation:

//..
[[package]]
name = "gdk-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 //..
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 //..
]

[[package]]
name = "gio"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/gio#c8b2d3bce17dc4bb5562b83a73602ebf09fe201c"
dependencies = [
 //..
 "glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 //..
]

[[package]]
name = "gio-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 //..
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 //..
]

[[package]]
name = "glib"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/glib#65d9f4dc60b6119a5cb9cc8390c8bfc77cd13ef5"
dependencies = [
 "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
]

//..

I do not know if you mentioned, with your comment, that I put as I have the charge.toml now and that is working, so I leave it here:

Cargo.toml This seems to solve the problem but I do not know if it is the right way

[package]
//..

[dependencies]
gtk = { git = "https://github.com/gtk-rs/gtk" }
glib = { git = "https://github.com/gtk-rs/glib" }

[features]
default = ["gtk/v3_10"]

Full Cargo.lock before in show code snippet

[root]
name = "test_thread_gtk"
version = "0.1.0"
dependencies = [
 "gtk 0.1.3 (git+https://github.com/gtk-rs/gtk)",
]

[[package]]
name = "atk-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "bitflags"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "bitflags"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "c_vec"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "cairo-rs"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/cairo#680ccfdb1ea4509d42a0333bd5bd9d43d75db077"
dependencies = [
 "c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
 "glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "cairo-sys-rs"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/cairo#680ccfdb1ea4509d42a0333bd5bd9d43d75db077"
dependencies = [
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
 "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "gdk"
version = "0.5.3"
source = "git+https://github.com/gtk-rs/gdk#a585b1f09b0f059f2d6a14862258d374564c1ce3"
dependencies = [
 "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)",
 "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
 "gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)",
 "gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gio 0.1.3 (git+https://github.com/gtk-rs/gio)",
 "glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pango 0.1.3 (git+https://github.com/gtk-rs/pango)",
]

[[package]]
name = "gdk-pixbuf"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/gdk-pixbuf#09fafcfc515b9866d4aa88b026cc2261bf322350"
dependencies = [
 "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "gdk-pixbuf-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "gdk-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
 "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "gio"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/gio#c8b2d3bce17dc4bb5562b83a73602ebf09fe201c"
dependencies = [
 "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "gio-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "glib"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/glib#65d9f4dc60b6119a5cb9cc8390c8bfc77cd13ef5"
dependencies = [
 "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "glib-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "gobject-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "gtk"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/gtk#25f753392840348645855f60cbd08521043d5926"
dependencies = [
 "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)",
 "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
 "gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)",
 "gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)",
 "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gio 0.1.3 (git+https://github.com/gtk-rs/gio)",
 "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pango 0.1.3 (git+https://github.com/gtk-rs/pango)",
]

[[package]]
name = "gtk-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "atk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
 "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "lazy_static"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "libc"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "pango"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/pango#485658b9479671818c8d15877d2078f12c71ec78"
dependencies = [
 "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
]

[[package]]
name = "pango-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#9556f8fe2dd00cfce05614b290a09d683b4b4209"
dependencies = [
 "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
 "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "pkg-config"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"

[metadata]
"checksum atk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23"
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
"checksum c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6237ac5a4b1e81c213c24c6437964c61e646df910a914b4ab1487b46df20bd13"
"checksum cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)" = "<none>"
"checksum cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)" = "<none>"
"checksum gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)" = "<none>"
"checksum gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)" = "<none>"
"checksum gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gio 0.1.3 (git+https://github.com/gtk-rs/gio)" = "<none>"
"checksum gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum glib 0.1.3 (git+https://github.com/gtk-rs/glib)" = "<none>"
"checksum glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gtk 0.1.3 (git+https://github.com/gtk-rs/gtk)" = "<none>"
"checksum gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
"checksum libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "babb8281da88cba992fa1f4ddec7d63ed96280a1a53ec9b919fd37b53d71e502"
"checksum pango 0.1.3 (git+https://github.com/gtk-rs/pango)" = "<none>"
"checksum pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
Angel Angel
  • 19,670
  • 29
  • 79
  • 105
  • @Shepmaster Thanks for the link, I read the link, but I did not understand it very well, so after searching I found this -> http://doc.crates.io/specifying-dependencies.html And make this change in my **cargo.toml** `glib = { git = "https://github.com/gtk-rs/glib" }`And it seems to work but I do not know if it's the right way. – Angel Angel May 10 '17 at 02:27
  • The **Cargo.lock** *before* you used the git dependency for glib and *after* you added glib to Cargo.toml. The point in time when you had the problem: "being linked to by more than one package". – Shepmaster May 10 '17 at 21:37

0 Answers0