chunqian / go-raylib

go-raylib is a simple and easy-to-use library to enjoy videogames programming
zlib License
44 stars 3 forks source link

Latest commit won't compile on Linux #8

Closed makew0rld closed 3 years ago

makew0rld commented 3 years ago

When trying to compile basic_window.go on Linux, using the latest commit 6ee277f768c6, I get this error output:

/usr/bin/ld: ../../../../pkg/mod/github.com/chunqian/go-raylib@v0.0.0-20210327031704-6ee277f768c6/raylib/../lib/raylib/plat/linux/libraylib.a(text.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../../../pkg/mod/github.com/chunqian/go-raylib@v0.0.0-20210327031704-6ee277f768c6/raylib/../lib/raylib/plat/linux/libraylib.a(raudio.c.o): relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../../../pkg/mod/github.com/chunqian/go-raylib@v0.0.0-20210327031704-6ee277f768c6/raylib/../lib/raylib/plat/linux/libraylib.a(core.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../../../pkg/mod/github.com/chunqian/go-raylib@v0.0.0-20210327031704-6ee277f768c6/raylib/../lib/raylib/plat/linux/libraylib.a(models.c.o): relocation R_X86_64_32 against `.text' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../../../pkg/mod/github.com/chunqian/go-raylib@v0.0.0-20210327031704-6ee277f768c6/raylib/../lib/raylib/plat/linux/libraylib.a(utils.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../../../pkg/mod/github.com/chunqian/go-raylib@v0.0.0-20210327031704-6ee277f768c6/raylib/../lib/raylib/plat/linux/libraylib.a(textures.c.o): relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../../../pkg/mod/github.com/chunqian/go-raylib@v0.0.0-20210327031704-6ee277f768c6/raylib/../lib/raylib/plat/linux/libraylib.a(shapes.c.o): warning: relocation against `sincosf@@GLIBC_2.2.5' in read-only section `.text'
collect2: error: ld returned 1 exit status

No binary is built.

This is the default gcc flags Go is using. I never set this myself.

➤ go env GOGCCFLAGS
-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build988534947=/tmp/go-build -gno-record-gcc-switches

I had trouble changing it to use -fPIE instead and gave up.

The latest commit that successfully compiles on Linux is 90039dae19642319a4dacd502b7dbb9db272ecde , before any .a files have been added. There were some warnings, but a binary was made and it worked fine.

My suggestion: Just remove the .a files. What is the point of having them? I'd rather just build the library myself.

chunqian commented 3 years ago

I'm clear Give me some time to solve the redefine problem

makew0rld commented 3 years ago

More info:

If I download 6ee277f and delete the .a files, and use that, I get this error:

➤ go build
# github.com/chunqian/go-raylib/raylib
/usr/bin/ld: cannot find -lraylib
collect2: error: ld returned 1 exit status

So it's not just a problem in .a files I guess.

chunqian commented 3 years ago

@makeworld-the-better-one I found a way to solve redefine in cgo I will probably push it tomorrow after testing Static libraries will be removed

chunqian commented 3 years ago

@makeworld-the-better-one fixed remove static libraries no warnings

makew0rld commented 3 years ago

Can confirm 83ff695c6830 compiles on Linux with no warnings or issues. Thank you!