gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
https://gtk-rs.org/
MIT License
1.24k stars 82 forks source link

Failed in compiling the crate gtk #1027

Closed Hyijun closed 4 years ago

Hyijun commented 4 years ago

I tried to use the example code and compile the project, rustc threw an error that gtk codes used some undefined references. However, the code analysis of the IDE told me that the code is no problem. The version of Rust toolchain I use is stable-x86_64-pc-windows-gnu. I also tried nightly-x86_64-pc-windows-gnu, but it didnt work as well. Below is the error message:

= note: J:\rust\gui_test\target\debug\deps\libgtk-872dc5035e98281d.rlib(gtk-872dc5035e98281d.gtk.m24f10wf-cgu.10.rcgu.o): In function `_$LT$gtk..auto..gesture_long_press..GestureLongPress$u20$as$u20$glib..types..StaticType$GT$::static_type::hb2a9296689ef6a81':
          C:\Users\18231\.cargo\registry\src\github.com-1ecc6299db9ec823\gtk-0.8.1\src\auto/gesture_long_press.rs:32: undefined reference to `gtk_gesture_long_press_get_type'
          J:\rust\gui_test\target\debug\deps\libgtk-872dc5035e98281d.rlib(gtk-872dc5035e98281d.gtk.m24f10wf-cgu.11.rcgu.o): In function `gtk::auto::gesture_pan::GesturePan::get_orientation::hb8cefbbf04dc75a7':
          C:\Users\18231\.cargo\registry\src\github.com-1ecc6299db9ec823\gtk-0.8.1\src\auto/gesture_pan.rs:51: undefined reference to `gtk_gesture_pan_get_orientation'
          J:\rust\gui_test\target\debug\deps\libgtk-872dc5035e98281d.rlib(gtk-872dc5035e98281d.gtk.m24f10wf-cgu.11.rcgu.o): In function `gtk::auto::gesture_pan::GesturePan::set_orientation::h317ab29d9e4da5f3':
          C:\Users\18231\.cargo\registry\src\github.com-1ecc6299db9ec823\gtk-0.8.1\src\auto/gesture_pan.rs:59: undefined reference to `gtk_gesture_pan_set_orientation'
          J:\rust\gui_test\target\debug\deps\libgtk-872dc5035e98281d.rlib(gtk-872dc5035e98281d.gtk.m24f10wf-cgu.11.rcgu.o): In function `_$LT$gtk..auto..flags..PlacesOpenFlags$u20$as$u20$glib..types..StaticType$GT$::static_type::ha9e5e217d0f640ff':
          C:\Users\18231\.cargo\registry\src\github.com-1ecc6299db9ec823\gtk-0.8.1\src\auto/flags.rs:622: undefined reference to `gtk_places_open_flags_get_type'
        (some similar messages are omitted here)

error: aborting due to previous error

Is it because I didn't reference some necessary crates?

sdroege commented 4 years ago

That means that the GTK version you're using is too old. gtk_places_open_flags_get_type was added with 3.10, which is much older than the minimum supported version 3.14. gtk_gesture_long_press_get_type() was added with 3.14, as were the others.

As it didn't fail compiling earlier with a version error this means also that you're pkg-config is not correctly configured and it goes into some magic fallback path that usually fails.