gtk-rs / gtk3-rs

Rust bindings for GTK 3
https://gtk-rs.org
MIT License
508 stars 90 forks source link

Cross compiling of gtk-rs project from linux to windows failing #437

Open fightthepower opened 3 years ago

fightthepower commented 3 years ago

I have read preparing rust tutorial and I have followed all the steps , including a additional step recommended by this stack overflow answer rustup toolchain install stable-x86_64-pc-windows-gnu


rustup target add x86_64-pc-windows-gnu
rustup toolchain install stable-x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-gnu
sudo apt-get install mingw-w64

But when compiling its failing at the last stage with this error

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1

 = note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgtk-3
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk-3
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpangocairo-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpango-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -latk-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo-gobject
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk_pixbuf-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgio-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -latk-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk-3
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpangocairo-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpango-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk_pixbuf-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo-gobject
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpango-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk_pixbuf-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo-gobject
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgio-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          collect2: error: ld returned 1 exit status

error: aborting due to previous error; 2 warnings emitted

error: could not compile `project`

OS : Linux (Ubuntu) rustc : 1.50.0 gtk-rs : 0.9.2 (features version 3_22, same as the host trying to compile)

sdroege commented 3 years ago

Do you have Windows versions of the GTK libraries and its dependencies installed and their pkg-config file visible to the environment where you're building your code?

fightthepower commented 3 years ago

Sorry I didn't know that we have to install these as well.

pacaur -S mingw-w64-gcc mingw-w64-freetype2-bootstrap mingw-w64-cairo-bootstrap
pacaur -S mingw-w64-harfbuzz
pacaur -S mingw-w64-pango
pacaur -S mingw-w64-poppler
pacaur -S mingw-w64-gtk3

I thought it would be automatically added with sudo apt-get install mingw-w64. It looks like in ubuntu there is no sudo apt install way to install those packages. Anyhow I found another tutorial where they cross compiled gtk-rs using docker. I tried to repeat the same with there docker but while building the image at here ADD package.sh /usr/bin/package.sh it crashes.

Is there any other docker images or files which do the same thing?

MGlolenstine commented 3 years ago

@fightthepower: Have you tried compiling it using this docker container? I've used it before and it does run well.

fightthepower commented 3 years ago

@MGlolenstine Yes I tried with rust-crosscompile but sadly there is some issue with one of my dependency "rusqlite". I have reported that issue but sofar nothing.

MGlolenstine commented 3 years ago

Can you try with sqlite-bundled feature? https://github.com/rusqlite/rusqlite