andlabs / ui

Platform-native GUI library for Go.
Other
8.33k stars 651 forks source link

linux compile issue #248

Closed rawsh closed 6 years ago

rawsh commented 6 years ago

Using the documentation example, a (fedora) compile for windows fails:

env CC=x86_64-w64-mingw32-gcc CCX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64 go build -v

# gui
./gui.go:8: undefined: ui.Main
./gui.go:9: undefined: ui.NewEntry
./gui.go:10: undefined: ui.NewButton
./gui.go:11: undefined: ui.NewLabel
./gui.go:12: undefined: ui.NewVerticalBox
./gui.go:13: undefined: ui.NewLabel
./gui.go:17: undefined: ui.NewWindow
./gui.go:19: undefined: ui.Button
./gui.go:22: undefined: ui.Window
./gui.go:23: undefined: ui.Quit
./gui.go:23: too many errors

A normal build works fine.

andlabs commented 6 years ago

Try also adding CGO_ENABLED=1.

rawsh commented 6 years ago

@andlabs huh, that fixed it. Before cgo gave a different error

andlabs commented 6 years ago

Right, you need to explicitly enable cgo when cross-compiling. Good luck!

WolfgangMau commented 6 years ago

didn't worked out for me I'm compiling on osx - here I can build it without problems: ➜ chamgo-ui git:(master) ✗ gox -osarch darwin/amd64 Number of parallel builds: 7

--> darwin/amd64: github.com/user/chamgo-ui ➜ chamgo-ui git:(master) ✗

but rather linux nor windows gets crosscompiled: ➜ chamgo-ui git:(master) ✗ export CGO_ENABLED=1 ➜ chamgo-ui git:(master) ✗ gox -osarch windows/386 Number of parallel builds: 7

--> windows/386: github.com/user/chamgo-ui

1 errors occurred: --> windows/386 error: exit status 2 Stderr: # github.com/user/chamgo-ui ./chamgo-ui.go:18:9: undefined: ui.Main ./chamgo-ui.go:25:18: undefined: ui.NewLabel ./chamgo-ui.go:26:24: undefined: ui.NewLabel ./chamgo-ui.go:27:19: undefined: ui.NewCombobox ./chamgo-ui.go:32:19: undefined: ui.NewButton ./chamgo-ui.go:33:25: undefined: ui.NewLabel ./chamgo-ui.go:35:22: undefined: ui.NewHorizontalBox ./chamgo-ui.go:39:16: undefined: ui.NewVerticalBox ./chamgo-ui.go:45:21: undefined: ui.NewLabel ./chamgo-ui.go:46:16: undefined: ui.NewCombobox ./chamgo-ui.go:46:16: too many errors

same program without ui get's (cross)compiled without problems: ➜ chamgo git:(xmodem) ✗ gox -osarch windows/amd64 Number of parallel builds: 7

--> windows/amd64: github.com/user/chamgo ➜ chamgo git:(xmodem) ✗ gox -osarch windows/386
Number of parallel builds: 7

--> windows/386: github.com/user/chamgo ➜ chamgo git:(xmodem) ✗

andlabs commented 6 years ago

You also need to set $CC and $CXX to point to the appropriate C and C++ compilers. Other than that, I wouldn't know unless you enabled verbose or debug output on gox, because I don't know what gox is doing.