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

Go get fails on linux_amd64 #180

Closed
mixedCase opened this issue Aug 13, 2016 · 30 comments
Closed

Go get fails on linux_amd64 #180

mixedCase opened this issue Aug 13, 2016 · 30 comments

Comments

@mixedCase
Copy link

Get the following when trying to go get:

$ LANG=C go get -u github.com/andlabs/ui
# github.com/andlabs/ui
/usr/bin/ld: andlabs/ui/libui_linux_amd64.a(libui-combined.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

LANG=C merely used to have the errors in English.

@mixedCase
Copy link
Author

Trying to run the example here after the failed go get also returns the same error.

@andlabs
Copy link
Owner

andlabs commented Aug 14, 2016

What version of Go?

@mixedCase
Copy link
Author

$ go version
go version go1.6.3 linux/amd64

@joeblew99
Copy link

joeblew99 commented Aug 25, 2016

how did you install the gcc tools ?

what linux are you on ?

@andlabs
Copy link
Owner

andlabs commented Aug 25, 2016

The binaries might not be built with PIC. I'll need to see how to get cmake to do it, if I didn't already...

@mixedCase
Copy link
Author

@joeblew99 Through my distro's package manager. I'm using Arch Linux, GCC is version 6.1.1.

@joeblew99
Copy link

Ok. I am on Ubuntu and used the package manager on Ubuntu.

I am wondering if I can help and land with the cross built.
Maybe the xgo github project would help ? I am only guessing about this though.

If others like me would compile everything I could also maybe help with the matching of the c code to the golang code.

@emersion
Copy link
Contributor

xgo works for macOS, but not Windows (see karalabe/xgo#55).

You need the latest mingw-w64 (5.0rc2) which hasn't yet been released.

@joeblew99
Copy link

https://packages.debian.org/search?keywords=mingw-w64

Debian experimental looks to have the mingw-w64 (5.0rc2). Maybe worth trying in a VM ?

@joeblew99
Copy link

Ok thanks Emerson.
Looks like I have to wait

@mixedCase
Copy link
Author

@andlabs How did you build these .a files and from what?

@andlabs
Copy link
Owner

andlabs commented Sep 7, 2016

Simply with

cmake -DBUILD_SHARED_LIBS=OFF ..
make

on Ubuntu 16.04.

I forget how or if I specified PIC.

@mixedCase
Copy link
Author

@andlabs I can confirm that it works if I add -fPIC to libui's compiler instructions in CMakeLists.txt. Could you recompile and upload?

@mixedCase
Copy link
Author

Pinging @andlabs in case you missed the last comment.

@andlabs
Copy link
Owner

andlabs commented Nov 10, 2016

I'll look into it soon.

@txthinking
Copy link

Should I install mingw-w64 (5.0rc2) and set CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ before go get github.com/andlabs/ui ?

@andlabs
Copy link
Owner

andlabs commented Nov 16, 2016

Yes.

@txthinking
Copy link

On Archlinux. installed gtk3.

Go

$ go version
go version go1.7.3 linux/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tx/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build663071203=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

install mingw-w64-crt-git-5.0.rc2.r114.g563731c-1

$ yaourt -S mingw-w64-crt-git

get ui

$ CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go get -v -u github.com/andlabs/ui
github.com/andlabs/ui (download)
github.com/andlabs/ui
# github.com/andlabs/ui
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -ldl
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lgtk-3
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lgdk-3
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lpangocairo-1.0
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lpango-1.0
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -latk-1.0
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lcairo-gobject
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lcairo
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lgio-2.0
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lgobject-2.0
/usr/lib/gcc/x86_64-w64-mingw32/6.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lglib-2.0
collect2: error: ld returned 1 exit status

@andlabs
Copy link
Owner

andlabs commented Nov 16, 2016

You must also set $GOOS.

@txthinking
Copy link

@andlabs Thanks, it works with mingw-w64-crt-git. #155

@NickCao
Copy link

NickCao commented Jan 28, 2017

The same issue for me on Ubuntu GNOME 16.10. Not fixed yet.

@andlabs
Copy link
Owner

andlabs commented Jan 28, 2017

What version of MinGW-w64 does Ubuntu 16.10 come with?

@NickCao
Copy link

NickCao commented Jan 29, 2017

I was just building for Linux, maybe MinGW is not required?

@andlabs
Copy link
Owner

andlabs commented Jan 29, 2017

Do you want to build Linux-native programs or Windows-native programs?

@NickCao
Copy link

NickCao commented Feb 1, 2017

Linux-native (Sorry for responding so late. I was traveling these days.)

@andlabs
Copy link
Owner

andlabs commented Feb 1, 2017

Then your $GOOS is not set properly. What does go env print?

@NickCao
Copy link

NickCao commented Feb 2, 2017

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/nickcao/Projects/Go"
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

@andlabs
Copy link
Owner

andlabs commented Feb 2, 2017

Your environment is correct for a Linux build. I'm not sure why it's trying to build the Windows one...

@NickCao
Copy link

NickCao commented Feb 2, 2017

Maybe building it manually instead of using go get can fix that?

@mixedCase
Copy link
Author

Closing this because I no longer have the original issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants