therecipe / qt

Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
GNU Lesser General Public License v3.0
10.49k stars 748 forks source link

Linking tests and example program on Mac OS fails #54

Closed jtgoral closed 8 years ago

jtgoral commented 8 years ago

MacBook-Air:qtexample jgoral$ qtdeploy build desktop

build_1 output:# qtexample /usr/local/go/pkg/tool/darwin_amd64/link: running clang++ failed: exit status 1 ld: warning: option -s is obsolete and being ignored ld: warning: object file (/var/folders/2g/nwmr0b_x7fjcl243279wdrm40000gq/T/go-link-020709116/000000.o) was built for newer OSX version (10.10) than being linked (10.8) ld: warning: object file (/var/folders/2g/nwmr0b_x7fjcl243279wdrm40000gq/T/go-link-020709116/000003.o) was built for newer OSX version (10.11) than being linked (10.8) ld: internal error: atom not found in symbolIndex(__ZN10QTextCodec12codecForNameEPKc) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

error:exit status 2

therecipe commented 8 years ago

Hey

Which go version do your use? Which mac os version do you use? (sierra?) Which xcode version do you use?

Did the setup.sh run successfully? (Did the examples show up?)

jtgoral commented 8 years ago

go 1.7.1,Yosemite, setup.sh tests failed in linker with the message like above.

therecipe commented 8 years ago

And which Xcode version do you have installed? This should show you your current version number: xcodebuild -version

jtgoral commented 8 years ago

Xcode 7.2. I tried to install 8.0 on Yosemite but it did not like me.

On the second box I have no problems with ElCapitan and Xcode 8.0. What I had to do was a symlink from my Qt installation in HOME/Qt to /usr/local, chmod 777 /usr/local/go/bin to install qtdeploy and I had to download 10.11 SDK from https://github.com/phracker/MacOSX-SDKs/releases because Xcode 8.0 removed previous SDKs and installed 10.12.

It would be nice to have location of Qt installation through an environmental variable instead of hard coded to /usr/local.

therecipe commented 8 years ago

Thanks for the info about the missing macOS sdk (the iOS 9 sdk is probably gone as well). I will fix this and also make it possible to define a custom Qt installation through an environment variable.

And about the atom not found in symbolIndex(__ZN10QTextCodec12codecForNameEPKc) error, it seems like the -s flag is causing that.

Could you replace this line in ( qt/internal/deploy/deploy.go:397 ) ldFlags += "\"-s\" \"-w\" \"-r=/usr/local/Qt5.7.0/5.7/clang_64/lib\""

with this line:

ldFlags += "\"-w\" \"-r=/usr/local/Qt5.7.0/5.7/clang_64/lib\""

and run this go run $GOPATH/src/github.com/therecipe/qt/internal/setup/test.go

It will rebuild qtdeploy + qtmoc and also build all the examples.

jtgoral commented 8 years ago

Building now. First gui app is on the screen....Video_player is on... This was it. All tests compiled without any errors. This case can be closed if it makes to the Git repository.

therecipe commented 8 years ago

I pushed the changes. https://github.com/therecipe/qt/commit/4c104f8cca5cad6ec4f5fd62524856b7ef0ce737

Both problems with Xcode should be fixed now (the missing sdk (8.0) + the wrong ldflag (7.2)). You can now define a custom Qt location with QT_INSTALL_DIR before running the setup. And you don't have to chmod the go/bin dir anymore, because qtdeploy and qtmoc are now build in $GOPATH/bin and symlinked into /usr/local/bin.

skys215 commented 6 years ago

Hi,

I got similar error with different go/macOS/Qt/XCode version.

ld: warning: object file (/var/folders/43/w8f5q8gd34q4xrqnljv22b340000gn/T/go-link-134411465/000012.o) was built for newer OSX version (10.12) than being linked (10.11)
....
exit status 1

go version: go version go1.11 darwin/amd64 macOS version: 10.12.6(Sierra) mbp 13' Early 2015 Qt version: 5.11.1 XCode version:

Xcode 9.2
Build version 9C40b

Should I run go run $GOPATH/src/github.com/therecipe/qt/internal/setup/test.go as your last reply told to?

Thanks

skys215 commented 6 years ago

I think I mangaged it to work. I installed above-mentioned MacOSX-SDK which match my macOS version(10.12), I installed lower version of go(1.10), because it seems that go 1.11 is not supported yet and I reinstalled the goqt.

therecipe commented 6 years ago

@skys215

Hey Go 1.11 should work, and you can usually ignore the

ld: warning: object file (...) was built for newer OSX version (10.12) than being linked (10.11)

warnings

skys215 commented 6 years ago

I'll try when I need to upgrade go version then.