-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: fedora22/amd64/go1.5.1 cgo link problem: /usr/bin/ld: /tmp/go-link-891155565/000000.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC #13017
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
Comments
problem reproduces on ubuntu12.04 using gcc 4.9.1 as well. Still with go1.5.1 and GO15VENDOREXPERIMENT=1.
|
Why does it think it is trying to create a shared object? Do you have a "#cgo LDFLAGS: -shared" somewhere? Can you attach the output of "go build -ldflags=-v"? |
shouldn't -buildmode=c-shared try to create shared objects? here is the build attempt with I add -ldflags=-v to the go build invocation
in the above run on ubuntu12.04 LDFLAGS and CFLAGS are here (but no -shared):
|
Sorry, I missed the -buildmode=c-shared. I would gently suggest that you highlight that next time--it's not the common case and it was not obvious in the initial report. The only problematic thing I see in your log is this: gcc -c -o interface.o cpp/interface.cpp -Iinclude/ I don't think that is coming from Go. I think it's coming from your Makefile. I think you need to compile that object with the -fPIC option, as the system linker error message suggests. |
Thanks for being so polite, Ian. I strive to emulate your example of good manners. Indeed I should have highlighted the buildmode=c-shared. I was so immersed in the project that it didn't occur to me that it was not obvious. And yes you nailed it. My initial gcc call on interface.cpp was indeed the problem. I just couldn't figure out from those linker errors which of the many compiled files it was complaining about. Thank you so much for pointing out the problem. Compilation on linux and OSX can't be expected to require the same build flags, I must keep reminding myself. For anyone in the future looking at this same issue, it was fixed by adding -fPIC to the very first gcc call (the one that I wrote by hand myself to compile some glue code).
|
problem summary: on linux fedora22/amd64 eith gcc 5.1.1 and go1.5.1, I'm getting a link error from CGO. This same command set seems to work fine on OSX.
details:
source code for R-3.2.2: https://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz
source code for rmq package: https://github.com/glycerine/rmq
The text was updated successfully, but these errors were encountered: