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 Compilation to linux error. #66538

Closed
Wan9xy opened this issue Mar 26, 2024 · 0 comments
Closed

Cross Compilation to linux error. #66538

Wan9xy opened this issue Mar 26, 2024 · 0 comments

Comments

@Wan9xy
Copy link

Wan9xy commented Mar 26, 2024

Go version

go version1.21.3

Output of go env in your module/workspace:

set GO111MODULE=on
set GOARCH=arm64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Administrator\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=linux
set GOPATH=C:\Users\Administrator\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:/Users/Administrator/go/go1.21.5
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\Administrator\go\go1.21.5\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.5
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=D:\src\ximei-cloud\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-fPIC -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build614450073=/tmp/go-build -gno-record-gcc-switches

What did you do?

// yd.go
type wzyd struct {
*WangZhe
YdToken aToken

uid      string
token    string
sig      string
battleId string
client   *resty.Client

lock *sync.Mutex
//ctx  context.Context

selectedRole Role

Tim *timsdk.TimSdk

}

// wzry.go
type WangZhe struct {
//currentGoods platform.Goods
account string
gameAppid string
ydAppid string

accountType platform.AccountType
tokenFn     func(appid string) (platform.Token, error)

ctx    context.Context
cancel context.CancelFunc

client *resty.Client

*wzyd
*game

}

// game.go
type game struct {
*WangZhe
GameToken aToken

//currentGoods platform.Goods
accountType platform.AccountType

//ctx context.Context

}

the 3 files are in one package.

What did you see happen?

When I build program:
In Windows and Mac, it is success, but build in linux it can't work, I don't know why.
eg:

  1. In Windows 11:
    $env:GOOS="windows";$env:GOARCH="amd64";go build .\cmd\http_server\
    NO ERROR HERE.
    $env:GOOS="Linux";$env:GOARCH="amd64";go build .\cmd\http_server\
    game\wzry\game.go:18:3: undefined: WangZhe
    game\wzry\game.go:19:12: undefined: aToken
    game\wzry\game.go:28:9: undefined: aToken
    game\wzry\game.go:31:10: undefined: WangZhe
    game\wzry\game.go:66:16: undefined: aToken
    game\wzry\game.go:88:8: g.SetCache undefined (type *game has no field or method SetCache, but does have setCache)
    game\wzry\yd.go:29:3: undefined: WangZhe
    game\wzry\yd.go:30:10: undefined: aToken
    game\wzry\yd.go:47:9: undefined: aToken
    game\wzry\yd.go:70:10: undefined: WangZhe
    game\wzry\game.go:88:8: too many errors

  2. In MACOS:
    GOOS=darwin go build ./cmd/http_server/
    NO ERROR HERE.
    GOOS=linux go build ./cmd/http/server/
    the seem error with Windows11.

What did you expect to see?

it could be built in local machine, and also can use go run.
when i built that with another platform, it didn't work.
By the way, in linux, the program can not running.

wxy@xyubuntu:~/xm-cloud$ go run ./cmd/http_server/

ximei-cloud/game/wzry

game/wzry/game.go:18:3: undefined: WangZhe
game/wzry/game.go:19:12: undefined: aToken
game/wzry/game.go:28:9: undefined: aToken
game/wzry/game.go:31:10: undefined: WangZhe
game/wzry/game.go:66:16: undefined: aToken
game/wzry/game.go:88:8: g.SetCache undefined (type *game has no field or method SetCache, but does have setCache)
game/wzry/yd.go:29:3: undefined: WangZhe
game/wzry/yd.go:30:10: undefined: aToken
game/wzry/yd.go:47:9: undefined: aToken
game/wzry/yd.go:70:10: undefined: WangZhe
game/wzry/game.go:88:8: too many errors

@Wan9xy Wan9xy closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant