andlabs / ui

Platform-native GUI library for Go.
Other
8.33k stars 651 forks source link

Can't install #272

Closed DeadNumbers closed 6 years ago

DeadNumbers commented 6 years ago
go get -v -u github.com/andlabs/ui
github.com/andlabs/ui (download)
github.com/andlabs/ui
# github.com/andlabs/ui
/usr/sbin/ld: ../Go/src/github.com/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/sbin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

go version go1.10 linux/amd64 libui 0.3.5.alpha-1 gcc 7.3.0

andlabs commented 6 years ago

I thought I fixed this argh; will go back and fix it for real later

ghost commented 6 years ago

@andlabs is there a work-around? The README's build instructions now just refer to go get.

mdejong commented 6 years ago

I just tried to use go get on Mac OSX and it failed like so:

go version go version go1.9.4 darwin/amd64 go get -v -u github.com/andlabs/ui github.com/andlabs/ui (download) github.com/andlabs/ui go build github.com/andlabs/ui: invalid flag in #cgo LDFLAGS: /Users/modejong/Development/GoPackages/src/github.com/andlabs/ui/libui_darwin_amd64.a

andlabs commented 6 years ago

@serussell it's a problem with libui's build process in which I need to figure out why -fPIC isn't being applied... because I thought I did apply it explicitly

@mdejong upgrade to Go 1.10 or wait for 1.9.5

ghost commented 6 years ago

@andlabs Understood. Can you paste the build command (and arguments) in the meantime so we can build the project?

mdejong commented 6 years ago

I found that setting the following ENV var also worked around the build problem on MacOSX:

export CGO_LDFLAGS_ALLOW=".*"

andlabs commented 6 years ago

@serussell I just do cmake -DBUILD_SHARED_LIBS=OFF and then make.

SirNeural commented 6 years ago

getting an error on OSX High Sierra 10.3.3 using Go 1.10 go get -v -u github.com/andlabs/ui github.com/andlabs/ui (download) github.com/andlabs/ui go build github.com/andlabs/ui: invalid flag in #cgo LDFLAGS: -mmacosx-version-min=10.8 ive bypassed the error by using the export CGO_LDFLAGS_ALLOW=".*" but I then get a warning which I'm not sure if I should be worried about. go get -v -u github.com/andlabs/ui github.com/andlabs/ui (download) github.com/andlabs/ui ld: warning: object file (/Users/neural/golang/src/github.com/andlabs/ui/libui_darwin_amd64.a(libui-combined.o)) was built for newer OSX version (10.12) than being linked (10.8)

andlabs commented 6 years ago

Again, the "invalid cgo flag" stuff is a Go 1.10 thing, because of a recent security vulnerability. CGO_LDFLAGS_ALLOW=".*" defeats that whole problem, so you should probably alter this regex to be fine-tuned toward the specific cases until the 1.10.1 patch comes out that will handle the things that weren't patched in.

@mdejong @SirNeural where did each of you get the .* workaround from?

The "was built for newer version" stuff is another libui build bug I thought I fixed already.

SirNeural commented 6 years ago

@andlabs I just saw the reply from @mdejong and tried it, seemed to help get the go get command working Anything I can do to help give more information on this issue?

vanillaSprinkles commented 6 years ago

Using ArchLinux here and the CGO_LDFLAGS_ALLOW=".*" does not work to get this installed (get the same error as OP)

tried to use all of the new CGO ALLOW vars with no success (CGO_CFLAGS_ALLOW=".*" CGO_CXXFLAGS_ALLOW=".*" CGO_LDFLAGS_ALLOW=".*")

Go 1.10.1 is expected march 1st, hopefully it helps.

andlabs commented 6 years ago

Right, the issue the OP has has nothing to do with the cgo options whitelist.

vanillaSprinkles commented 6 years ago

(sorry I missed relaying some info in the wee hours last night): I tried also setting CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go get github.com/andlabs/ui which changed the OP error into a cgo issue (got the idea to set the flags from an old issue#)

Edit: well after looking at all this again I did it right finally; pulled down libui, cmake + make and copied the out/libui.a over ui's libui_linux_amd64.a allowing a go build && go install

Maybe the release section of libui can have the .o and .a files as well and ui can just reference them?

drahoslove commented 6 years ago

@andlabs, I tried to compile libui by myself, replacing libui_linux_amd64.a by out/libui.a and then go install ui. As @vanillaSprinkles did. But it fails with these errors:

/tmp/go-build458073604/b001/_x010.o: In function `newFont':
./draw.go:88: undefined reference to `uiDrawLoadClosestFont'
/tmp/go-build458073604/b001/_x010.o: In function `_cgo_2fc1135dc6ba_Cfunc_uiDrawFontFamiliesFamily':
/tmp/go-build/cgo-gcc-prolog:327: undefined reference to `uiDrawFontFamiliesFamily'
/tmp/go-build458073604/b001/_x010.o: In function `_cgo_2fc1135dc6ba_Cfunc_uiDrawFontFamiliesNumFamilies':
/tmp/go-build/cgo-gcc-prolog:344: undefined reference to `uiDrawFontFamiliesNumFamilies'
/tmp/go-build458073604/b001/_x010.o: In function `_cgo_2fc1135dc6ba_Cfunc_uiDrawListFontFamilies':
/tmp/go-build/cgo-gcc-prolog:408: undefined reference to `uiDrawListFontFamilies'
... and few others such lines

Is it possible, that current libui is not compatible with current ui? Which version is then?

andlabs commented 6 years ago

Yep, groan. Will need to update all the APIs :|

drahoslove commented 6 years ago

Would you appreciate some helping hand? :) Is it only about renaming or are these complicated API changes?

andlabs commented 6 years ago

Er wait I reread, you are building libui from source, so I assume you are building it from master. master has breaking API changes. You'll need to build from one of the stable tarball releases. Sorry!

drahoslove commented 6 years ago

You are right, thanks. Now I have a different problem - my program panics at the start, but it might not be a problem with (lib)ui.

virtualsue commented 6 years ago

I'm getting this same error on debian 9, go 1.10. Is it best to build from source? Will try that now.

andlabs commented 6 years ago

Duplicate of: