#How to build Tauri with `x86_64-pc-windows-gnu`

17 messages · Page 1 of 1 (latest)

tardy lark
#

I'm aware the focus is on windows-msvc but in order to use a certain crate I need the project to be windows-gnu. Any info on how one is able to build for windows-gnu would be appreciated

ebon eagle
#

Just follow the Rust instructions. https://rust-lang.github.io/rustup/installation/windows.html
It's not explained further there but the However, many library crates will not be able to compile until the full MSYS2 with MinGW has been installed. is likely important. For tauri this may be required to compile the PE resources (icon and manifest for your .exe)

#

That should just work then. If not, please reach out with the issues you have / errors your see.

tardy lark
# ebon eagle That _should_ just work then. If not, please reach out with the issues you have ...

I tried installing mingw64 with pacman -S mingw-w64-x86_64-toolchain, and the environment path is C:\msys64\mingw64\bin, but trying to run cargo tauri dev brings a C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: error: export ordinal too large: 135046 error, and when I tried to use rust-lld, I get: note: rust-lld: error: <root>: undefined symbol: _DllMainCRTStartup. Did I do something wrong?

ebon eagle
#

i assume cargo build (inside src-tauri) throws the same error?

#

also, can you check whether you have a .cargo/config.toml file (not to be confused with Cargo.toml) somewhere that may force build.target to the msvc toolchain?

tardy lark
# ebon eagle also, can you check whether you have a .cargo/config.toml file (not to be confus...

I started a new Tauri 2.0-rc project with the cargo create-tauri I think it's called, running cargo build inside src-tauri does throw the same error, and my config looks as following:

[build]
target = "x86_64-pc-windows-gnu"

[target.x86_64-pc-windows-gnu]
linker = "rust-lld"

I have tested to make sure it's working properly, when I remove rust-lld I get the rust-lld error, and the export error when I remove it

ebon eagle
#

can you also share the output of rustup show and the tauri info command please?

#

it kinda sounds like you're still using the msvc toolchain but with the gnu target which would be a bit problematic

tardy lark
#

rustup show

Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\Benjamin McCann\.rustup

installed toolchains
--------------------

stable-x86_64-pc-windows-gnu (default)
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-gnu

active toolchain
----------------

stable-x86_64-pc-windows-gnu (default)
rustc 1.81.0 (eeb90cda1 2024-09-04)
#

cargo tauri info

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64) 
    ✔ WebView2: 128.0.2739.79
    ✔ MSVC: Visual Studio Community 2022  
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-gnu (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.14.0
    - npm: 10.7.0

[-] Packages
    - tauri 🦀: 2.0.0-rc.15
    - tauri-build 🦀: 2.0.0-rc.12
    - wry 🦀: 0.43.1
    - tao 🦀: 0.30.1
    - tauri-cli 🦀: 2.0.0-rc.16
    - @tauri-apps/api : 2.0.0-rc.5
    - @tauri-apps/cli : 2.0.0-rc.16

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.0-rc.3
    - @tauri-apps/plugin-shell : 2.0.0-rc.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
tardy lark
ebon eagle
#

okay, took a while but i just tried it myself now.
0) I did not create a config.toml file

  1. rustup default stable-gnu
  2. download msys2
  3. open mingw64 shell (though installing the package should work in the ucrt shell too)
  4. pacman -S mingw-w64-x86_64-binutils (this is really the only package we care about for a default tauri app since it contains the resource compiler)
  5. In my default powershell env i ran $env:PATH+=";A:\msys2\mingw64\bin" -> obviously change A:\ to your path
  6. tauri build
#

I assume you installed the ucrt packages instead of mingw. ucrt is more like the msvc toolchain so i assume it's not compatible with rust's gnu toolchain/target

tardy lark
# ebon eagle okay, took a while but i just tried it myself now. 0) I did _not_ create a confi...

You're good, I'm mostly trying to make an app for fun. Thank you so much for your help.
I uninstalled everything msys2 and ran cargo clean, then followed the steps. However, interestingly step 4 didn't install gcc, leading to the new error: 'gcc' is not recognized as an internal or external command, operable program or batch file.. I can confirm it wasn't in C:\msys2\mingw64\bin and that gcc -v didn't work.
So, I ran pacman -S mingw-w64-x86_64-toolchain, gcc -v work... but I get the same errors. I wonder if it's installing too much? I'll try not installing anything but gcc and what you posted, but I don't think that's the issue

#

This was made in a un-altered Tauri 2.0-rc tauri-create instance, installed mingw-w64-x86_64-gcc and mingw-w64-x86_64-binutils, got the same errors

ebon eagle
#

so i'm on a different machine now so i can't try stuff until tomorrow but i know that i also didn't have gcc installed.