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

cross compile(linux->windows) with CGO failed #3719

Closed
fcying opened this issue Sep 1, 2024 · 0 comments · Fixed by #3795
Closed

cross compile(linux->windows) with CGO failed #3719

fcying opened this issue Sep 1, 2024 · 0 comments · Fixed by #3795
Labels
Bug Something isn't working

Comments

@fcying
Copy link
Contributor

fcying commented Sep 1, 2024

Description

I use wails build -platform windows, if use CGO, it can't build.

fcying@home:~/test/wails $ wails build -platform windows
Wails CLI v2.9.1                                                                                                                                                                                                          # Build Options

Platform(s)        | windows
Compiler           | /usr/local/bin/go
Skip Bindings      | false
Build Mode         | production
Devtools           | false
Frontend Directory | /home/fcying/test/wails/frontend
Obfuscated         | false
Skip Frontend      | false
Compress           | false
Package            | true
Clean Bin Dir      | false
LDFlags            |
Tags               | []
Race Detector      | false
                                                                                                                                                                                                                                            # Building target: windows/amd64

  • Generating bindings: Done.
  • Installing frontend dependencies: Done.
  • Compiling frontend: Done.
  • Generating application assets: Done.
  • Compiling application: # wails
./main.go:16:9: undefined: NewApp
  ERROR   exit status 1
  ERROR   exit status 1

after set CC CXX

export CXX=x86_64-w64-mingw32-g++
export CC=x86_64-w64-mingw32-gcc

wails build -platform windows                                                                                                                                                                                    Wails CLI v2.9.1                                                                                                                                                                                                                            

# Build Options

Platform(s)        | windows
Compiler           | /usr/local/bin/go
Skip Bindings      | false
Build Mode         | production
Devtools           | false
Frontend Directory | /home/fcying/test/wails/frontend
Obfuscated         | false
Skip Frontend      | false
Compress           | false
Package            | true
Clean Bin Dir      | false
LDFlags            |
Tags               | []
Race Detector      | false

# Building target: windows/amd64
# Building target: windows/amd64

  • Generating bindings:   ERROR
          # runtime/cgo
          gcc_linux_amd64.c: In function ‘_cgo_sys_thread_start’:
          gcc_linux_amd64.c:57:9: error: unknown type name ‘sigset_t’; did you mean ‘_sigset_t’?
             57 |         sigset_t ign, oset;
                |         ^~~~~~~~
                |         _sigset_t
          gcc_linux_amd64.c:62:9: error: implicit declaration of function ‘sigfillset’ [-Werror=implicit-function-declaration]
             62 |         sigfillset(&ign);
                |         ^~~~~~~~~~
          gcc_linux_amd64.c:57:23: error: unused variable ‘oset’ [-Werror=unused-variable]
             57 |         sigset_t ign, oset;
                |                       ^~~~
          cc1: all warnings being treated as errors

          exit status 1

  ERROR
          # runtime/cgo
          gcc_linux_amd64.c: In function ‘_cgo_sys_thread_start’:
          gcc_linux_amd64.c:57:9: error: unknown type name ‘sigset_t’; did you mean ‘_sigset_t’?
             57 |         sigset_t ign, oset;
                |         ^~~~~~~~
                |         _sigset_t
          gcc_linux_amd64.c:62:9: error: implicit declaration of function ‘sigfillset’ [-Werror=implicit-function-declaration]
             62 |         sigfillset(&ign);
                |         ^~~~~~~~~~
          gcc_linux_amd64.c:57:23: error: unused variable ‘oset’ [-Werror=unused-variable]
             57 |         sigset_t ign, oset;
                |                       ^~~~
          cc1: all warnings being treated as errors

          exit status 1

To Reproduce

  1. wails init -t vue-ts -n wails
  2. cd wails && wails build -platform windows #build ok
  3. add example c code to app.go
package main

/*
void test() {
}
*/
import "C"

  1. wails build -platform windows # error
  2. export CC=x86_64-w64-mingw32-gcc
  3. export CXX=x86_64-w64-mingw32-g++
  4. wails build -platform windows # error

Expected behaviour

cross build work fine

Screenshots

No response

Attempted Fixes

No response

System Details

wails doctor


          Wails Doctor


                                                                                                                                                                                                                                            # Wails
Version         | v2.9.1
Package Manager | apt

# System
┌───────────────────────────────────────────────────┐                                                                                                                                                                                       | OS           | Debian GNU/Linux                   |
| Version      | 12                                 |
| ID           | debian                             |
| Go Version   | go1.22.3                           |
| Platform     | linux                              |
| Architecture | amd64                              |
| CPU          | AMD Ryzen 7 5700X 8-Core Processor |
| GPU          | Unknown                            |
| Memory       | 20GB                               |
└───────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────┐                                                                                                                                                                    | Dependency | Package Name          | Status    | Version             |
| *docker    | docker.io             | Available | 20.10.24+dfsg1-1+b3 |
| gcc        | build-essential       | Installed | 12.9                |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.38-2~deb12u1   |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.44.3-1~deb12u1    |
| npm        | npm                   | Installed | 10.5.0              |
| *nsis      | nsis                  | Available | 3.08-3+deb12u1      |
| pkg-config | pkg-config            | Installed | 1.8.1-1             |
└────────────────────── * - Optional Dependency ───────────────────────┘

# Diagnosis
Optional package(s) installation details:
  - docker: sudo apt install docker.io
  - nsis: sudo apt install nsis

 SUCCESS  Your system is ready for Wails development!


### Additional context

_No response_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant