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

Windows example demo won't build #62

Open
martin-guthrie-docker opened this issue Jul 10, 2018 · 6 comments
Open

Windows example demo won't build #62

martin-guthrie-docker opened this issue Jul 10, 2018 · 6 comments

Comments

@martin-guthrie-docker
Copy link

martin-guthrie-docker commented Jul 10, 2018

Getting this build error,

C:\Program Files (x86)\Console2>go get github.com/golang-ui/nuklear/cmd/nk-example
/# github.com/go-gl/glfw/v3.2/glfw
In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0:
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration]
wcscpy(monitor->win32.adapterName, adapter->DeviceName);
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration]
if (wcslen(first->win32.displayName))
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration]
return wcscmp(first->win32.displayName, second->win32.displayName) == 0;
^~~~~~
/# github.com/golang-ui/nuklear/cmd/nk-example
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\Users\Martin\AppData\Local\Temp\go-link-052590467\go.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

GCC:

C:\Program Files (x86)\Console2>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)

Go:

C:\Program Files (x86)\Console2>go version
go version go1.10.3 windows/amd64

@xlab
Copy link
Member

xlab commented Jul 10, 2018

go.o: file not recognized: File format not recognized

very weird, looks like your toolchain is broken..

Are you sure that Target: mingw32 is an amd64 target? Please double-check the arch.

@martin-guthrie-docker
Copy link
Author

martin-guthrie-docker commented Jul 11, 2018

Note the GCC output above, it says Target mingw32. I googled around and saw that one could set environment variable MSYSTEM to mingw64, which I did, no change in result.

I am able to build other Go programs, specifically some easy tutorial go programs.

Here is full output,

Martin@MartinoOne ~
$ go version
go version go1.10.3 windows/amd64

Martin@MartinoOne ~
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)

Martin@MartinoOne ~
$ go install github.com/golang-ui/nuklear/nk
/# github.com/go-gl/glfw/v3.2/glfw
In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0:
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration]
wcscpy(monitor->win32.adapterName, adapter->DeviceName);
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration]
if (wcslen(first->win32.displayName))
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration]
return wcscmp(first->win32.displayName, second->win32.displayName) == 0;
^~~~~~

Martin@MartinoOne ~
$ go get github.com/golang-ui/nuklear/cmd/nk-example
/# github.com/go-gl/glfw/v3.2/glfw
In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0:
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration]
wcscpy(monitor->win32.adapterName, adapter->DeviceName);
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration]
if (wcslen(first->win32.displayName))
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration]
return wcscmp(first->win32.displayName, second->win32.displayName) == 0;
^~~~~~
/# github.com/golang-ui/nuklear/cmd/nk-example
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\Users\Martin\AppData\Local\Temp\go-link-702485631\go.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

@martin-guthrie-docker
Copy link
Author

martin-guthrie-docker commented Jul 11, 2018

okay I "think" I understand what the issue is.... The install of MinGW I have is for 32bit systems, but my machine is a 64bit system. I was lead to cygwin for MinGW 64bit version, and when I build in a cygwin shell, I get,

$ go get github.com/golang-ui/nuklear/cmd/nk-example
/# github.com/go-gl/glfw/v3.2/glfw
In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0:
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration]
wcscpy(monitor->win32.adapterName, adapter->DeviceName);
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration]
if (wcslen(first->win32.displayName))
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration]
return wcscmp(first->win32.displayName, second->win32.displayName) == 0;
^~~~~~
/# github.com/golang-ui/nuklear/cmd/nk-example
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32
collect2: error: ld returned 1 exit status

So I think its an issue with using the "MinGW installer" link that is in the instructions, which is a 32bit gcc, versus my machine being 64bit. But I am just hypothesizing...

I was unable to find the missing files, and I suspect cygwin doesn't have these libs, so this may be a deeper make issue, which is beyond my pay grade...

I am willing to get to the bottom of this but I would need direction...

@xlab
Copy link
Member

xlab commented Jul 11, 2018

Based on all the experience I have, it seems that you've gone too far off the radar, the later errors are not common and it seems that your MinGW is totally broken.

It's important that Go's arch and GCC's arch match, you can get 64/64 or 32/32 on the same 64-bit machine, but they must match.

@martin-guthrie-docker
Please remove any trace of MinGW/MSYS from your system and install by the steps from README:
screen shot 2018-07-11 at 23 08 23

MSYS 1.0:
https://sourceforge.net/projects/mingw/files/latest/download

@martin-guthrie-docker
Copy link
Author

martin-guthrie-docker commented Jul 13, 2018

Thank you for the help.

I removed my previous MinGW, and installed new (64bit) one from this link,

https://sourceforge.net/projects/mingw-w64/?source=typ_redirect

I do start the batch file msys to get a console.

The result,

C:>go get github.com/golang-ui/nuklear/cmd/nk-example
# github.com/go-gl/glfw/v3.2/glfw
In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0:
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration]
wcscpy(monitor->win32.adapterName, adapter->DeviceName);
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration]
if (wcslen(first->win32.displayName))
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration]
return wcscmp(first->win32.displayName, second->win32.displayName) == 0;
^~~~~~
# github.com/golang-ui/nuklear/cmd/nk-example
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In function glfwSwapBuffers': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:609: undefined reference to __assert_func'
C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In function glfwExtensionSupported': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:642: undefined reference to __assert_func'
C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In function glfwGetProcAddress': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:707: undefined reference to __assert_func'
C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In function glfwGetInputMode': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:153: undefined reference to __assert_func'
C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In function glfwSetInputMode': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:174: undefined reference to __assert_func'
C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o:C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:262: more undefined references to __assert_func' follow C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000024.o: In function _cgo_cb1d4e13f0d1_C2func_calloc':
/cygdrive/c/Users/Martin/AppData/Local/Temp/go-build054383554/b001/cgo-gcc-prolog:42: undefined reference to __errno' /cygdrive/c/Users/Martin/AppData/Local/Temp/go-build054383554/b001/cgo-gcc-prolog:44: undefined reference to __errno'
C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000028.o: In function nk_insert_window': C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18504: undefined reference to __assert_func'
C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18505: undefined reference to __assert_func' C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18499: undefined reference to __assert_func'
C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18498: undefined reference to __assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000028.o: In function nk_do_button':
C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:14139: undefined reference to __assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000028.o:C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:14141: more undefined references to __assert_func' follow
collect2.exe: error: ld returned 1 exit status

It seems this is a known issue,

go-gl/glfw#202
In that issue it says to select 686 target, but that is for 32bit...

I tried using msys2 from https://www.msys2.org
but got the same result.

BTW, gcc version info:

C:>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)

@vitesse-ftian
Copy link

Same here, undefined reference to __assert_func. I am using msys2 + go 1.12.

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

3 participants