Skip to content

cmd/go: running gcc failed when compiling to Android #40993

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

Closed
hasanAjsf opened this issue Aug 23, 2020 · 1 comment
Closed

cmd/go: running gcc failed when compiling to Android #40993

hasanAjsf opened this issue Aug 23, 2020 · 1 comment

Comments

@hasanAjsf
Copy link

I tried to solve 40988# by compiling the file at Ubuntu WSL, Ubuntu inside Windows 10.

I got go installed and running:

$ go version
go version go1.15 linux/amd64

I got gcc installed and running
image

While compiling the same code, I got the below error:

output:

# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-178415548/go.o:(.data+0x0): undefined reference to `x_cgo_callers'
/tmp/go-link-178415548/go.o:(.data+0x8): undefined reference to `x_cgo_init'
/tmp/go-link-178415548/go.o:(.data+0x10): undefined reference to `x_cgo_mmap'
/tmp/go-link-178415548/go.o:(.data+0x18): undefined reference to `x_cgo_munmap'
/tmp/go-link-178415548/go.o:(.data+0x20): undefined reference to `x_cgo_notify_runtime_init_done'
/tmp/go-link-178415548/go.o:(.data+0x28): undefined reference to `x_cgo_sigaction'
/tmp/go-link-178415548/go.o:(.data+0x30): undefined reference to `x_cgo_thread_start'
/tmp/go-link-178415548/go.o:(.data+0x38): undefined reference to `x_cgo_setenv'
/tmp/go-link-178415548/go.o:(.data+0x40): undefined reference to `x_cgo_unsetenv'
/tmp/go-link-178415548/go.o:(.data+0x48): undefined reference to `_cgo_yield'
collect2: error: ld returned 1 exit status

image

@ianlancetaylor
Copy link
Member

Please show us text as plain text, not as an image. Thanks.

First, you need to set CGO_ENABLED=1. But that won't be enough: in order to cross-compile a Go program that uses C code, you need to have a C cross-compiler. Go cross-compiles automatically, but C does not.

Closing because this is not a bug. We don't use the issue tracker for questions. You will get better and faster help using a forum. Please see https://golang.org/wiki/Questions. Thanks.

@golang golang locked and limited conversation to collaborators Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants