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

_cgo_export.c:1:0: error: -fPIC ignored for target (all code is position independent) [-Werror] #34871

Closed
Zhangzijing opened this issue Oct 13, 2019 · 1 comment

Comments

@Zhangzijing
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.13.1 windows/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\i\AppData\Local\go-build
set GOENV=C:\Users\i\AppData\Roaming\go\env
set GOEXE=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=linux
set GOPATH=E:\Sync\onedrive_pluvet\OneDrive - bupt.edu.cn\Code\MemoriBackend;C:\Go;C:\Users\i\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=C:\Users\i\AppData\Local\Temp\go-build664142882=/tmp/go-build -gno-record-gcc-s
witches

What did you do?

I'm trying to build for linux

mkdir bin 
set GOOS=linux
set GOARCH=amd64
set CGO_ENABLED=1
go get -x
go install -x

What did you expect to see?

Success

What did you see instead?

go build
# runtime/cgo
_cgo_export.c:1:0: error: -fPIC ignored for target (all code is position independent) [-Werror]
 /* Code generated by cmd/cgo; DO NOT EDIT. */
 ^
cc1.exe: all warnings being treated as errors
@dmitshur
Copy link
Contributor

dmitshur commented Oct 21, 2019

Hello,

Setting up your Windows system to enable cross-compilation to Linux can be tricky, and I suspect you're running into a problem due to misconfiguration there. There are some common questions and answers to this on stack overflow, for example see here.

We use this issue tracker for tracking bugs in Go, and this doesn't seem to be one, so I'll close this. If it turns out to be a bug, please provide more specific information and we can re-open.

For asking questions, please see:

@golang golang locked and limited conversation to collaborators Oct 20, 2020
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