Closed remorez closed 7 years ago
Hey @remorez I've made the thing working fine under Windows, I tried on Windows 7 32-bit. https://cl.ly/1r0j2Y3D2I2W/Screen%20Shot%202016-10-29%20at%2015.11.24.png
The key problem you had that your Windows doesn't have OpenGL 3, so the backend failed to link. I've migrated to OpenGL 2.1 and adjusted a couple of compile flags to make sure it builds fine.
There is a section dedicated to Windows in readme now: https://github.com/golang-ui/nuklear#windows
I think you'll find this trick useful:
$ CGO_CFLAGS="-I/c/dev/glfw-3.2.1/include" CGO_LDFLAGS="-L/c/dev/glfw-3.2.1/lib-mingw" go install github.com/golang-ui/nuklear/nk
So no need to copy the GLFW libs around, just put them somewhere and reference through CFLAGS/LDFLAGS on build time.
At last, I recommend you to check out this lib https://github.com/therecipe/qt maybe it will provide some rich features you'll need in your project, Nuklear is a cool thing but it's kinda minimalistic for any serious GUI development.
Have fun.
Hey @xlab, I tried to make this work on Windows (7, 64bit) but I was still getting ld.exe: cannot find -lglfw3
error - even when using CGO flags.
Then I tried to compile the example on Linux (Mint 18, 64bit) and got exactly same error.
After some digging I finally could make this work on Linux by compiling GLFW with BUILD_SHARED_LIBS
option following these instructions.
Thanks for all the tips and help @xlab! So, I fiddled with this on the same machine a bit more to get stuck on:
$ CGO_CFLAGS="-I/c/dev/glfw/include" CGO_LDFLAGS="-L/c/dev/glfw/lib-mingw-w64" go build github.com/golang-ui/nuklear/cmd/nk-example
# github.com/golang-ui/nuklear/cmd/nk-example
C:\go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\msys64\tmp\go-link-025673147\000002.o:wassert.c:(.text+0x4f5e0): multiple definition of `_wassert'
C:\msys64\tmp\go-link-025673147\000001.o:wassert.c:(.text+0xe650): first defined here
C:\msys64\tmp\go-link-025673147\000002.o:wassert.c:(.text+0x4f720): multiple definition of `_assert'
C:\msys64\tmp\go-link-025673147\000001.o:wassert.c:(.text+0xe790): first defined here
C:\msys64\tmp\go-link-025673147\000002.o:mingw_helpers.c:(.text+0x4f7e0): multiple definition of `_decode_pointer'
C:\msys64\tmp\go-link-025673147\000001.o:mingw_helpers.c:(.text+0xf700): first defined here
C:\msys64\tmp\go-link-025673147\000002.o:mingw_helpers.c:(.text+0x4f7f0): multiple definition of `_encode_pointer'
C:\msys64\tmp\go-link-025673147\000001.o:mingw_helpers.c:(.text+0xf710): first defined here
C:\msys64\tmp\go-link-025673147\000002.o:mingw_helpers.c:(.bss+0x4760): multiple definition of `mingw_app_type'
C:\msys64\tmp\go-link-025673147\000001.o:/tmp/go-build/github.com/go-gl/glfw/v3.2/glfw/_obj/_cgo_export.c:19: first defined here
collect2.exe: error: ld returned 1 exit status
Trying to get to bottom of this I configured everything from scratch on another Win 7 64-bit machine using following:
After making sure all is added to %PATH% I tried to compile the example and got exactly same set of errors as on the first machine. Dunno how useful this will be for you but I just wanted to let you know in case you want to check if there is problem related to 64-bit Windows.
@remorez It turns out there is a problem with CGO and MinGW as of today, I've found these issues as well:
The latter says this will be fixed in 1.8 (Feb, 2017).
But the first one provides a temporary solution and it worked for me! A MinGW64 build completed with no errors after the fix: -Wl,--allow-multiple-definition
. I updated the files.
Try it out please.
With your help @xlab I finally made this running on my Win7 64-bit.
To make example compile I ran following command from Git Shell:
CGO_CFLAGS="-I/c/dev/glfw/include" CGO_LDFLAGS="-L/c/dev/glfw/lib-mingw-w64" go build -o "$GOPATH/bin/nuklear.exe" -ldflags "-extldflags=-Wl,--allow-multiple-definition" github.com/golang-ui/nuklear/cmd/nk-example
@remorez I included that flag into the file that links GLFW, so should be working even without that extra flag by hand. Glad it finally worked, have fun.
After upgrade go to 1.8.7/1.9.4/1.10, then environment variable CGO_LDFLAGS_ALLOW
should be set to -Wl,--allow-multiple-definition
.
Reference: https://github.com/golang/go/issues/23672
CGO_LDFLAGS_ALLOW='-Wl,--allow-multiple-definition' go get/install
$env:CGO_LDFLAGS_ALLOW='-Wl,--allow-multiple-definition'
go get/install
Wanted to try this on Windows and after running:
go get github.com/golang-ui/nuklear/nk
it gave me:I have GLFW 3.2 for Go installed and I am using go1.7.3 windows/amd64. Also I have MinGW_x64 installed and added to path.
To troubleshoot I copied folder containing missing file:
%GOPATH%\src\github.com\go-gl\glfw\v3.2\glfw\glfw\include\GLFW
to nuklear folder:%GOPATH%\src\github.com\golang-ui\nuklear\nk
and building started to throw those errors:This project looks like what I need so please help me make it work.