#Default Tauri app won't build for target `x86_64-pc-windows-gnu`

41 messages · Page 1 of 1 (latest)

keen thistle
#

I want to build a Tauri app on Windows for the Rust target x86_64-pc-windows-gnu. I can't use the MSVC target because my app will depend on several dlls that are compiled with MinGW, and I can't recompile them for MSVC because a dependency requires gfortran.

Reproduce
My environment:

Create a template tauri app:

A:\repo\tauri-gnu-windows-2>npm create tauri-app@latest
✔ Project name · tauri-gnu-windows-2
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm)
✔ Choose your package manager · npm
✔ Choose your UI template · React - (https://reactjs.org/)
✔ Choose your UI flavor · TypeScript

Run cd tauri-gnu-windows-2 and npm install. Then run npm run tauri -- dev --target x86_64-pc-windows-gnu. This error occurs:

   Compiling tauri-gnu-windows-2 v0.0.0 (A:\repo\tauri-gnu-windows-2\tauri-gnu-windows-2\src-tauri)
   Compiling webview2-com v0.19.1
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va"

...

"-nodefaultlibs" "A:\\repo\\tauri-gnu-windows-2\\tauri-gnu-windows-2\\src-tauri\\target\\x86_64-pc-windows-gnu\\debug\\build\\tauri-gnu-windows-2-bf5a16e02a5fa2bb\\out/resource.lib" "C:\\Users\\Home\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: A:\repo\tauri-gnu-windows-2\tauri-gnu-windows-2\src-tauri\target\x86_64-pc-windows-gnu\debug\build\tauri-gnu-windows-2-bf5a16e02a5fa2bb\out/resource.lib: file not recognized: file format not recognized
          collect2.exe: error: ld returned 1 exit status


error: could not compile `tauri-gnu-windows-2`
devout mango
#

that's a bit tricky. we really only officially support msvc

#

can you post the output of the tauri info command just to be sure it initialized it correctly?

keen thistle
# devout mango can you post the output of the tauri info command just to be sure it initialized...
[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 114.0.1823.58
    ✔ MSVC:
        - Visual Studio Build Tools 2019
        - Visual Studio Build Tools 2022
        - Visual Studio Community 2022
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.16.1
    - npm: 9.5.1

[-] Packages
    - tauri [RUST]: 1.4.1
    - tauri-build [RUST]: 1.4.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: 1.4.0
    - @tauri-apps/cli [NPM]: 1.4.0

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React
    - bundler: Vite
#

This is interesting because it says msvc is selected, do I have to change that?

keen thistle
devout mango
devout mango
#

oh and the bundler doesn't include the dll for the webview iirc so you'll have to include that yourself as a resource

#

actually, can you try setting the gnu toolchain as the default?

#

Right now you're using the msvc toolchain to compile to the gnu target which can cause issues

#

especially for the resource compiler

keen thistle
keen thistle
devout mango
#

globally: rustup default stable-gnu

#

i'd have to look up how to do it project-wide myself if you prefer that

keen thistle
#

That did the trick, thanks so much!

keen thistle
#

Just need to sidecar the rest of the dlls

devout mango
#

it was fixed once but i was pretty sure we broke it again

#

but good for you then :D

#

wait, are you sure it's inside the msi/setup.exe ? I really only see code that copies it into the target dir but nothing about that in the bundler

keen thistle
#

Idk but I ran the msi and it showed up in program files

devout mango
#

coolio

keen thistle
#

I'll just make sure to not allow it to update tauri automatically in case it breaks later again

#

Honestly gnu is so close to being perfectly supported idk why it's not official

devout mango
#

because it wasn't that close until very recently

#

and it's generally considered worse than the msvc one, and less of an ecosystem standard 🤷

#

and nobody in the team wanna actually maintain it

keen thistle
#

Understandable. As long as it works on this version I’m good

devout mango
#

i mean, we try not to break it either. or not more than the msvc one

devout mango
devout mango
keen thistle
#

Interesting, I guess I could use that instead of sidecar to add my dlls

devout mango
#

well, i mean that's essentially what the resource feature does but that currently requires the dlls to be next to the tauri.conf.json file so a custom script may indeed be nicer

keen thistle
#

I could add something to the build.rs that copies them

brave belfry
#

Hello @keen thistle

keen thistle
brave belfry
#

could have 5-10 min ?