Skip to content
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

Can not link 0.6.0 on Windows -- undefined reference #794

Closed
TrionProg opened this Issue Mar 4, 2019 · 11 comments

Comments

Projects
None yet
3 participants
@TrionProg
Copy link

TrionProg commented Mar 4, 2019

Hello. I get error on cargo build

C:\Users\trionprog\.cargo\registry\src\github.com-1ecc6299db9ec823\gtk-0.6.0\src\auto/flags.rs:396: undefined reference to `gtk_font_chooser_level_get_type'

I am using Msys64 + Mingw 64. I've downloaded GTK just after 4 hours since 0.6.0 release, but could not build it, then I've used 0.5.0. I had some problems but solved it. I used both ways: configured cmd.exe and mingw64. I had some problems with pkg-config (I do not know where to install it and works it correctly), but it founds all -l...

Outputs:

whereis libgtk-3-0
libgtk-3-0: /c/msys64/mingw64/bin/libgtk-3-0.dll
 pacman -Ss pkgconfig
mingw32/mingw-w64-i686-ruby-pkg-config 1.3.0-1
    Implementation of pkg-config in ruby (mingw-w64)
mingw64/mingw-w64-x86_64-ruby-pkg-config 1.3.0-1
    Implementation of pkg-config in ruby (mingw-w64)
msys/perl-ExtUtils-PkgConfig 1.16-1 (perl-modules)
    The Perl Pkgconfig module
msys/pkg-config 0.29.2-1 (base-devel)
    A system for managing library compile/link flags
 pkg-config --libs gtk+-3.0
-LC:/msys64/mingw64/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lfribidi -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
 pkg-config --cflags gtk+-3.0
-mms-bitfields -pthread -mms-bitfields -IC:/msys64/mingw64/include/gtk-3.0 -IC:/msys64/mingw64/include/cairo -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/pango-1.0 -IC:/msys64/mingw64/include/fribidi -IC:/msys64/mingw64/include/atk-1.0 -IC:/msys64/mingw64/include/cairo -IC:/msys64/mingw64/include/pixman-1 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/freetype2 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/harfbuzz -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/gdk-pixbuf-2.0 -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/glib-2.0 -IC:/msys64/mingw64/lib/glib-2.0/include -IC:/msys64/mingw64/include
echo $GTK_LIB_DIR
C:\msys64\mingw64\lib
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Users/trionprog/.cargo/bin::/c/msys64/mingw64/bin

I also tryed cargo clean, I used rustup override add stable-gnu.

Cargo.toml

[dependencies]
cairo-rs = "0.6.0"
gio = "0.6.0"


[dependencies.gtk]
version = "0.6.0"
#features = ["v3_22"]
@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Mar 4, 2019

You forgot to check gtk version, at minimum my libgtk-3-0.dll has string gtk_font_chooser_level_get_type

> pkg-config --modversion gtk+-3.0
3.24.4

Note: GTK_LIB_DIR usually don't need with pkg-config

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Mar 4, 2019

Seems FontChooserLevel need manual version "3.22.30"

@TrionProg

This comment has been minimized.

Copy link
Author

TrionProg commented Mar 4, 2019

Seems FontChooserLevel need manual version "3.22.30"

my output

 pkg-config --modversion gtk+-3.0
3.22.30

Okey, unfortunately, I have old version from the box =(. Following by my old Arch experience, I tried

 pacman -Sy mingw-w64-x86_64-gtk3
cargo clean
cargo build

Yeh, it works! Thank you.

I think, you should add the information into Requirements with:

  • check if pkg-config installed and how to install
  • update version of gtk3
@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Mar 4, 2019

Very strange that on 3.22.30 you don't have this type, property defined for exactly same version

      <property name="level" version="3.22.30" writable="1" transfer-ownership="none">
        <doc xml:space="preserve">The level of granularity to offer for selecting fonts.</doc>
        <type name="FontChooserLevel"/>
      </property>
@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Mar 4, 2019

We only started filling section "Possible problems", so there long way to go.

@TrionProg Don't forget close issue.

@TrionProg

This comment has been minimized.

Copy link
Author

TrionProg commented Mar 5, 2019

Okey, but while it works(after update to 3.24.xx). Incidentally I need gdk::EventMask::POINTER_MOTION_MASK and others to enable some events, for example, for DrawingBox. Maybe you should include it in gdk::prelude? Or how can I use it without extern crate gdk? I also have question:how rust links with GTK for current version? Or version of GTK library is maximum available version?

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Mar 5, 2019

We prefer direct includes for types, prelude used only for traits.
You need add gdk as dependence and use extern crate gdk in Edition2015.

I also have question:how rust links with GTK for current version?
Or version of GTK library is maximum available version?

You can only specify what version you needed,
if pkg-config used then we checks if current version is high enough,
other cases need detect version before building and change your code.

@TrionProg

This comment has been minimized.

Copy link
Author

TrionProg commented Mar 5, 2019

Okey, thank you! Благодарю.

@martinber

This comment has been minimized.

Copy link

martinber commented Apr 15, 2019

Sorry for replying to this old issue. I'm unable to cross-compile from Fedora to Windows since I updated gtk-rs from 0.5.0 to 0.6.0:

gtk = { version = "0.6.0", features = ["v3_16"] }
gdk = { version = "0.10.0"}
gio = { version = "0.6.0"}
glib = { version = "0.7.0"}

Basically I'm using a Fedora docker image because Fedora provides mingw64 binaries:

dnf -y install file gcc make man sudo tar zip \
                      mingw64-gcc \
                      mingw64-freetype freetype freetype-devel \
                      mingw64-cairo mingw64-cairo-static cairo cairo-devel \
                      mingw64-harfbuzz harfbuzz harfbuzz-devel \
                      mingw64-pango pango pango-devel \
                      mingw64-poppler poppler poppler-devel \
                      mingw64-gtk3 gtk3 gtk3-devel \
                      mingw64-glib2-static glib2 glib2-devel \
                      atk atk-devel \
                      mingw64-winpthreads mingw64-winpthreads-static

I have mingw64-gtk3 and gtk3-devel version 3.22.26 and I get the same error as OP:

 = note: /home/rustacean/src/target/x86_64-pc-windows-gnu/release/deps/libgtk-fbdd835063fb864b.rlib(gtk-fbdd835063fb864b.gtk.73asppjq-cgu.7.rcgu.o):gtk.73asppjq-cgu.7:(.text+0xa265): undefined reference to `gtk_font_chooser_level_get_type'
          collect2: error: ld returned 1 exit status

Full output on this pastebin, every step I did can be seen on this Dockerfile and this entrypoint.sh.

If I build on Debian for GNU/Linux using libgtk-3-dev version 3.22.11-1 it works. I've been trying to set up a mingw64 environment on Arch Linux without success (I never used Arch before and looks like the mingw-w64-gtk3 has circular dependencies I'm unable to resolve).

So I wanted to ask:

  • Do I need mingw-w64-gtk3 version 3.24.xx or it should work with 3.22.26? Note that I use the feature "v3_16" of gtk-rs so as far as I know I need version >= 3.16.

Thank you very much!

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Apr 16, 2019

While https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#GtkFontChooser--level says "Since: 3.22.30",
in http://repo.msys2.org/mingw/x86_64/ even mingw-w64-x86_64-gtk3-3.22.30-1-any.pkg.tar.xz don't contains "gtk_font_chooser_level_get_type",
it only found in mingw-w64-x86_64-gtk3-3.24.0-1-any.pkg.tar.xz.
also all other functions says "3.24", so I assume that it just typo.
Added PR to gtk-rs\gtk

Also slightly strange that --target=x86_64-pc-windows-gnu uses x86_64-w64-mingw32-gcc

@martinber

This comment has been minimized.

Copy link

martinber commented Apr 16, 2019

Just wanted to say that #804 fixed my problems, thank you! Now I can use my Fedora image with mingw64-gtk3 version 3.22.26.

If someone finds this issue, for now I made it work modifying my Cargo.toml to point to git versions of gtk-rs crates:

gtk = { git = "https://github.com/EPashkin/gtk.git", branch = "fontchooserlevel_version", features = ["v3_16"] }
gdk = { git = "https://github.com/gtk-rs/gdk.git" }
gio = { git = "https://github.com/gtk-rs/gio.git" }
glib = { git = "https://github.com/gtk-rs/glib.git" }

I also had to add Some()s to a few gtk-rs function calls, I guess because of changes likely to come in 0.7.0. More details on martinber/noaa-apt@ce5c7c3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.