#Help with compiling my app

10 messages · Page 1 of 1 (latest)

crimson hinge
#

Hi, i'm new to Rust and yesterday I made an app with gtk and I can compile it for my system. I'm running Manjaro Linux ( I did cargo build --release). Now I wanted to release it for Windows and macOs. For windows building i tried cargo build --release --target=x86_64-pc-windows-msvc but it fails (i'll give the console output in the file under this message). I maybe misunderstood something as I'm really new to this language (and btw i'm French so sorry for my grammatical errors). Anyone could help me to solve my problem please?

#

Here is my Cargo.toml if needed:

[package]
name = "SkymBootstrap"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gtk = { version = "0.6.6", package = "gtk4"}
glib = "0.17.10"
tokio = { version = "1.29.1", features = ["full"] }
reqwest = "0.11.18"
flate2 = "1.0.26"
tar = "0.4.38"
zip = "0.6.6"
dirs = "5.0.1"
md5 = "0.7.0"
serde_json = "1.0.100"
dusty cedar
#
  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.```
says right here at the bottom of that log
crimson hinge
#

Thanks, so here is what I did:

export PKG_CONFIG_SYSROOT_DIR=/usr
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig

But now I get a new error:

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

with a lot of files not found, so I maybe miss something. I'm search since a few hours on the internet about it but for now I can't figure out how to fix it
Note: I tried to compile with cargo build --target=x86_64-pc-windows-gnu --release

spare hound
# crimson hinge Hi, i'm new to Rust and yesterday I made an app with gtk and I can compile it fo...

For MacOs, you pretty much have to build on MacOs. There are (unsupported) workarounds, but basically you have to build for Mac/IOS on Mac.
See also: https://github.com/rust-lang/rust/issues/112501 and https://github.com/tpoechtrager/osxcross#how-does-it-work

For cross compiling to windows-msvc, you will need to install the Visual C/C++ Build Tools edit: Runtime, I suggest using xwinto install the required things https://github.com/Jake-Shadle/xwin .

For cross compiling when using additional libraries (on any non-host target basically), you will to have the versions of those libraries for the target where the cross-linker expects them to be (It looks like for x86_64-w64-mingw32-gcc, that's /usr/x86_64-w64-mingw32/lib, at least on my machine)

GitHub

Rust compilation on Ubuntu 22.04.2 LTS with target x86_64-apple-darwin fails with a build error: cc: error: unrecognized command-line option '-arch' cargo generated a cc command that can...

GitHub

A utility for downloading and packaging the Microsoft CRT headers and libraries, and Windows SDK headers and libraries needed for compiling and linking programs targeting Windows. - GitHub - Jake-S...

GitHub

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux) - GitHub - tpoechtrager/osxcross: Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)

vast tinsel
#

if you still have the issue after installing them, you can try to feed the paths for each of them by adding a file in .cargo/config.toml inside your project

#

something like this :

#
[target.x86_64-pc-windows-msvc]
rustflags = [
  "-Lnative=/mingw64/bin/",
  "-Lnative=/where/mingw64/is/installed/bin",
] ```