andlabs / ui

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

Build linux execution file on debian 9 failed #282

Closed squaredice closed 6 years ago

squaredice commented 6 years ago

Failed to create execution file on linux in docker container.

Container run with this command: docker run -ti -v path/to/files:/go/src golang bash, golang is official image with last golang version.

go get -v -u github.com/andlabs/ui works only like this: GOOS=windows CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go get -v -u github.com/andlabs/ui

Execution files for windows builds normal by: GOOS=windows CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -ldflags -H=windowsgui

When try to change GOOS to linux got this:

# runtime/cgo
gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:62:2: error: unknown type name 'sigset_t'
  sigset_t ign, oset;
  ^~~~~~~~
gcc_linux_amd64.c:67:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_linux_amd64.c:62:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1: all warnings being treated as errors

Installed: libgtk-3-dev, mingw-w64

go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build817048499=/tmp/go-build -gno-record-gcc-switches"

uname -a: Linux 4b0d492ecd42 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 GNU/Linux

andlabs commented 6 years ago

How are you running the Linux build?

squaredice commented 6 years ago

GOOS=linux CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build

andlabs commented 6 years ago

You are trying to build Linux code with a Windows compiler. Remove the environment variables.

squaredice commented 6 years ago

go build:

# github.com/andlabs/ui
/usr/bin/ld: github.com/andlabs/ui/libui_linux_amd64.a(libui-combined.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
andlabs commented 6 years ago

In that case, duplicate of #230.

Keep in mind that each individual gcc executable can only build for a single platform, so x86_64-w32-mingw-gcc can only build 64-bit Windows binaries (that's what the MinGW part means), whereas just plain gcc conventionally means it can only build binaries for whatever OS and architecture you are using.