-
Notifications
You must be signed in to change notification settings - Fork 63
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
build as a c Library, but faile #30
Comments
ME TOO/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 |
also hitting this issue, only reproducible on linux, works fine on darwin, both arm64 and amd64 /usr/bin/ld: /go/pkg/mod/github.com/valyala/[email protected]/libzstd_linux_amd64.a(cover.o): warning: relocation against `stderr@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: /go/pkg/mod/github.com/valyala/[email protected]/libzstd_linux_amd64.a(zdict.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation) easy to reproduce with just package main
// #cgo CFLAGS: -fPIC
import "C"
import "github.com/valyala/gozstd"
//export Compress
func Compress(msg *C.char) *C.char {
input := []byte(C.GoString(msg))
output := gozstd.Compress(nil, input)
return C.CString(string(output))
}
func main() {} then go build -o zstd.so -buildmode=c-shared . note: the cgo directive doesn't work, I just added as the error message suggested, but it makes no difference |
alright, issue found, the c archive for linux amd64 wasn't built with example git clone https://github.com/valyala/gozstd.git ../gozstd
cd ../gozstd
git checkout v1.17.0 # or whatever release you want # could be parsed from go.mod
MOREFLAGS=-fPIC make clean libzstd.a
cd - # wherever your package is
go mod edit -replace github.com/valyala/gozstd=../gozstd now the build works like a charm 🙂 now... is this a bug when the @valyala sorry for the tag, but it would be really nice to get your input |
I got this error when I want to execute this command Cleaning library completed
CC obj/conf_6d8c1dc6b1841212cc254358d8403b5f/static/debug.o
cc: internal compiler error: Segmentation fault (program as)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.
Makefile:210: recipe for target 'obj/conf_6d8c1dc6b1841212cc254358d8403b5f/static/debug.o' failed
make[2]: *** [obj/conf_6d8c1dc6b1841212cc254358d8403b5f/static/debug.o] Error 4
Makefile:107: recipe for target 'libzstd.a' failed
make[1]: *** [libzstd.a] Error 2
make[1]: Leaving directory '/data00/home/gaopengyang/project/github/gozstd/zstd/lib'
Makefile:15: recipe for target 'libzstd_linux_amd64.a' failed
make: *** [libzstd_linux_amd64.a] Error 2 My go version: 1.18 |
There is a problem with my GCC. I will fix it after reinstalling OS |
me too |
os: centos 7
want to compile into a C library with CGo, but get error:
/usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/bin/ld: /home/lcsuper/kong-zstd-go/vendor/github.com/valyala/gozstd/libzstd_linux_amd64.a(zdict.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
The text was updated successfully, but these errors were encountered: